Post

2 followers Follow
0
Avatar

Upload File Through API

I'm having trouble figuring out the correct POST statement to upload a file through the API.

I've been using the following steps provided in this post:

https://success.clarizen.com/hc/en-us/community/posts/360009224119-How-to-add-upload-image-in-project-files-using-Clarizen-Rest-API

 

  1. Create a Document object using https://api.clarizen.com/V2.0/services/data/CreateAndRetrieve;
  2. Create an AttachmentLink object between the project and the document created in step 1 using https://api.clarizen.com/V2.0/services/data/CreateAndRetrieve;
  3. Perform GET on https://api.clarizen.com/V2.0/services/files/GetUploadUrl;
  4. Perform POST of your file to the URL returned by step 3;
  5. Perform POST on https://api.clarizen.com/V2.0/services/files/Upload with documentId(entityId) from step 1 and fileInformation parameters to attach the file to the project.

 

I have tried POSTing my locally stored file to the URL I received in Step 3 over and over, but it continually doesn't work. I'm simply trying this through curl right now, and everything works great until I get to Step 4: 
"Perform POST of your file to the URL returned by GetUploadUrl"

 

The closest I've gotten is receiving the following individual error codes after each separate attempt that I'm hoping you can look up in the logs to tell me what I'm missing:

2psE3ESTtiDMckG87UUB7X

1X1q0iU1qouUy6gVyQJd0z

3elWf51hv9WUZhKUhITqWz

2Gc9CBAD2X1O27cFFu9keo 

S0lzFpbFdYw8ppsSP2WKa 

3dWp56C01zc7p3pJqJwM5T

The error message text preceding the code was:

"WeΓÇÖre sorry, something seems to have gone wrong. If you want our team to investigate please open a support ticket and include this error code"

Unfortunately, when I opened a ticket, I was told they couldn't help because this is an API call and I should post on this forum instead.

 

Ideally, can you provide me with an example post statement that should be successful? 

 

Do I need to include the ApiKey authorization or not? I've tried both ways. I've also tried with single, double, and no quotes just to cover my bases. Single quotes return a message of being unable to read the file, but double quotes and no quotes give me the Clarizen error message and a code as mentioned above.

 

I've also tried relative and absolute local paths but they act the same.

 

Here's one example of what I've tried running:

curl -F "data=@testfile.jpg" https://api2.clarizen.com/v2.0/services/files/<UPLOADFILECODE>/uploadFile

 

Any help would be greatly appreciated. 

Chad Davis Answered

Please sign in to leave a comment.

1 comment

0
Avatar

Hello Chad,

I don't think this will work with a local file. I think the file needs to be on a server.

Due to this, I can't really test this myself. I'll see if I can get you an example though.

Roland

Roland Pumputis 0 votes
Comment actions Permalink