Post

3 followers Follow
0
Avatar

How to add/upload image in project files using Clarizen Rest API

Hi,

I am trying to upload files in a project using rest api but I did not find proper steps to achieve it. 

 

Jayant Rimza Answered

Please sign in to leave a comment.

4 comments

0
Avatar

Hi Jayant,

Here are the steps to upload a file via the 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.

Hope this helps.

Roland

Roland Pumputis 0 votes
Comment actions Permalink
0
Avatar

Roland, 

Can you help me understand what I'm missing in your Step 4?

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. 

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 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"

 

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

 

Chad Davis 0 votes
Comment actions Permalink
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