Answer the question
In order to leave comments, you need to log in
How to correctly form a Post request to the Redmine server?
Good afternoon. I'm trying to figure out how to add tasks to Redmine, but I constantly get an error 422. Judging by the Redmine manuals, this means that the message format is not correct. But also in these manuals it is said that there should be an error text for a value that the server does not like, but it does not exist. I actually did everything according to the example (example: www.redmine.org/projects/redmine/wiki/Rest_api_wit... ), and then I started experimenting. I have not found any more examples of working with the HttpCli component on the net. Redmine version is 2.6.0.stable. I am using Delphi XE. If anyone has experience, please share. Links to resources are also welcome. PS The example for getting the task works.
Answer the question
In order to leave comments, you need to log in
Interesting, is it still relevant?
422 can also pop up if the transmitted data contains an action that is "forbidden" for the user or incorrect data - for example, an attempt to set the due date is less than the start date.
www.sql.ru/forum/1129863/redmine-rest-api?mid=1694...
here in this message the second example helped me a lot (I also have Delphi XE 4)
Working example (with additional fields)
address:='https://АДРЕС/projects/НАЗВАНИЕ ПРОЕКТА/issues.xml?key=';
apiAccessKey := edit1.text; ///Api user key example
for I := 0 to memo1.Lines.Count-1 do
begin
date_due:=copy(memo5.Lines[i],7,4)+'-'+copy(memo5.Lines[i],4,2)+'-'+copy(memo5.Lines[i],1,2);
date_close:=copy(memo6.Lines[i],7,4)+'-'+copy(memo6.Lines[i],4,2)+'-'+copy(memo6.Lines[i],1,2);
date_check:=copy(memo7.Lines[i],7,4)+'-'+copy(memo7.Lines[i],4,2)+'-'+copy(memo7.Lines[i],1,2);
try
issue := TStringList.Create;
with issue do
begin
Add('issue[tracker_id=44');
Add('issue[subject='+memo1.Lines[i]);
Add('issue[description='+memo2.Lines[i]);
Add('issue[status_id=1');
Add('issue[priority_id=2');
Add('issue[assigned_to_id='+memo3.Lines[i]);
Add('issue[start_date='+formatdatetime('YYYY-MM-dd',now()));
Add('issue[due_date='+date_due);
Add('issue[fixed_version_id='+memo8.Lines[i]);
Add('issue[custom_field_values[166='+memo4.Lines[i]);
Add('issue[custom_field_values[76='+memo3.Lines[i]);
Add('issue[custom_field_values[106='+date_close);
Add('issue[custom_field_values[66='+date_check);
end;
try
idhttp1.Post(address+apiAccessKey,issue);
except
issue.Destroy;
raise;
end;
finally
issue.Destroy;
end;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question