CSharpBeginner
CSharpBeginner

Reputation: 611

Upload attachment field via REST API

I'm using Archer REST API to upload a new attachment.
After i'm uploaded the attachment i have a File Id, now i'm trying to update field of the record with the new attachment, what i'm trying in the request body:

{"Content":{"Id": 278800, "LevelId" : 222,"FieldContents" : {"21771" : {"Type" : 11, "Value" : {"File id" : "1738", "Value": "RestUpload.xml"}, "FieldId" : 21771}, "16108" : {"Type" : 1, "Value" : "RestAPI Text x3", "FieldId" : 16108}}

I got the following result:

{
"Links": [],
"RequestedObject": {
    "Id": 278800
},
"IsSuccessful": true,
"ValidationMessages": []
}

But only the Text field updated.
What i need to fix?
Thanks.

Upvotes: 0

Views: 1365

Answers (1)

bodie
bodie

Reputation: 91

The easiest way to see how to format a field in a PUT or POST is to make a GET call and look at how the field is formatted in the response. In this case, your request body should look like this:

{"Content":{"Id": 213726 , "LevelId" : 255,"FieldContents" : {"16751": {"Type" : 11, "Value" : [11,3], "FieldId": 16751}}}}

Note that the list of file IDs attached to this record is an array, and must be represented as a comma-delimited list of ids in contained in square brackets.

Upvotes: 1

Related Questions