Creating a attachment


Currently contains 3 posts


February 20, 2020 20:35


I’m having trouble with creating an attachment. I’m not exactly sure how to paste code so here’s a copy of the below which might be easier to read

I ran this first to make sure the session and cid is correct

$ curl -i -H “Authorization: BEARER $SID” “$CID/attachments” HTTP/1.1 200 OK …. {"TotalRecords":1,“Results”:[{"AttachmentId":850588243286334,“Name”:“test.pdf”,“Type”:“Upload”,“Description”:“test.pdf”,Size,“Date”:“2020-02-20T14:55:18.21”}]}

I got the base 64 of this test text (10 digits)

$ echo -n “0123456789” | base64 MDEyMzQ1Njc4OQ==

I uploaded with this. Got an exception error about unsafe values.

curl -i -X POST -H “Content-Type: application/json” -H “Authorization: BEARER $SID” “$CID/attachments”: -d ‘{"CandidateId":9876543210, “CandidateAttachmentsBody”: {"Name": “MyTest.txt”, “Description”:“The test”, Size,“Data”: “MDEyMzQ1Njc4OQ==”,“Type”:"Upload"}}’

I tried variants such as the below with no luck. Including replacing the = with %3D

curl -i -X POST -H “Content-Type: application/json” -H “Authorization: BEARER $SID” “$CID/attachments”: -d ‘{"Name": “MyTest.txt”, “Description”:“The test”, Size,“Data”: “MDEyMzQ1Njc4OQ==”,“Type”:"Upload"}’


February 20, 2020 21:13


My first guess is the “Size” variable isn’t correct and I don’t believe you have to include it. Can you try removing it and posting?

Sample Add Attachment
POST ../candidates/123123123123123/attachments

“Name”: “HTMLTest.html”,
“Type”: “HTML”,
“Description”: “HTML Upload”,
“Data”: “PGRpdj5hYmMgdGVzdCBodG1sIGZpbGU8L2Rpdj4NCjxwPm1vcmUgdGV4dDwvcD4=”


February 20, 2020 22:16


Thanks. I think most of the variants I tried was using CandidateAttachmentsBody which is incorrect and I may have had a case typo somewhere. My code works now

Reply to thread