How to upload files via the HTTP API?

I try to send chat messages with an image attachment via the HTTP API.

So far, I can send a text message via 

POST https://WORKSPACE.jetbrains.space/api/http/chats/messages/send-message

→ This endpoint accepts an "attachments" list that I need help with:

I guess that attachments need to be uploaded via 

POST https://WORKSPACE.jetbrains.space/api/http/uploads {"storagePrefix": "attachment"}
→ Returns "/uploads/95318eb440914e425f00"

But I cannot upload the image via

PUT https://WORKSPACE.jetbrains.space/uploads/95318eb440914e425f00
→ Returns 404

PUT https://WORKSPACE.jetbrains.space/api/http/uploads/95318eb440914e425f00
→ Returns 404

There is no additional information on this in the API reference.
Do you have a sample or some clarification on how to upload an image and get its attachment ID? 

1
2 comments

Hello,

Thank you for your question!

Your approach is correct. The only thing that needs your attention is the URL of a PUT request. You have already added there the upload part but also need to add /your-file-name at the end to make it work.
Please let me know if the issue is resolved or more details/instructions are needed.

 

Margarita Kolotilova
JetBrains
http://www.jetbrains.com
The Drive to Develop

1

Hi Margarita,

Thanks for your prompt reply and the clarification!

Adding the filename solved the problem. Now the API returns the attachment ID and the chat message displays the image :)

-----

For the record, this is the correct API call:

PUT https://WORKSPACE.jetbrains.space/uploads/95318eb440914e425f00/my-image.png
→ Return value is "NMlwU8pB4ik" (plain text, no JSON)
0

Please sign in to leave a comment.