Delphi TRESTClient POST example --data vs. body

138 Views Asked by At

I am trying to update Jira comments via the provided curl example in Jira's documentation, but I am always getting HTTP error code 415 or 400 for the different functions.

curl -D- -u fred:fred -X POST --data {see below} -H "Content-Type: application/json" http://kelpie9:8081/rest/api/2/issue/QA-31/comment

{
    "body": "This is a comment regarding the quality of the response."
}
request.Method := TRESTRequestMethod.rmPost;
request.Params.AddItem('Content-Type','application/json',   TRESTRequestParameterKind.pkHTTPHEADER);
request.Resource := '/jira/rest/api/2/issue/QA-31/comment';
request.AddBody('{"This is a rest api comment update." }', ctAPPLICATION_JSON);
request.Params.AddItem('body','{"This is a rest api comment update." }' , TRESTRequestParameterKind.pkGETorPOST);
request.Params.AddItem('data','{"body": "This." }',TRESTRequestParameterKind.pkGETorPOST);
request.Body.Add('{"body": "This is a rest api comment update." }', ctAPPLICATION_JSON);
request.Execute;

What is the proper way to send the --data?

a) request.AddBody
b) request.Body.Add
c) request.Params.AddItem

BTW, query data with rmGet and PAT authentication is working fine.

0

There are 0 best solutions below