Creating a attachment

Tagged:

Currently contains 3 posts

Avatar

February 20, 2020 20:35

DBOND

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 https://justpaste.it/3jj9n

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

$ curl -i -H “Authorization: BEARER $SID” “https://www.pcrecruiter.net/rest/api/candidates/$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” “https://www.pcrecruiter.net/rest/api/candidates/$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” “https://www.pcrecruiter.net/rest/api/candidates/$CID/attachments”: -d ‘{"Name": “MyTest.txt”, “Description”:“The test”, Size,“Data”: “MDEyMzQ1Njc4OQ==”,“Type”:"Upload"}’

Avatar

February 20, 2020 21:13

Jarrid-PCRecruiter

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=”
}

Avatar

February 20, 2020 22:16

DBOND

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