How can I add an image attachment by URL via API (post)?

sangbok lee
sangbok lee EN Basic Posts: 2 Beginner
edited May 2023 in Ask the Community

Hi, in the API documentation, there's 'local:' (file) param only. How can I add an attachment by URL?

https://developers.meistertask.com/reference/post-attachment

By the way, unlike other API examples (GET/POST), the 'try-it' on the page never succeeded (400). I used Chrome and a PNG file.

Best Answer

  • Miša Hennin
    Miša Hennin Admin, MeisterLobster, EN Business Posts: 1,676 Community Admin
    Answer ✓

    I'd like to update this thread here with confirmation from the team - Right now, it's not possible to attach files using URL via MT API.

    If you'd like to submit a feature request, please head over to the feature request category and post your idea there.


Answers

  • Miša Hennin
    Miša Hennin Admin, MeisterLobster, EN Business Posts: 1,676 Community Admin

    Hey @anemochore,

    Thanks for reaching out.

    I've just confirmed this with our devs. The best way would indeed be to use a local file. However, it is possible to enter a URL in the browsing bar. This downloads the picture and saves it to INetCache automatically. Based on this, it should work.

    I hope this helps.

    Best,

    Miša

  • sangbok lee
    sangbok lee EN Basic Posts: 2 Beginner
    edited May 2023

    Hi, Miša Hennin. Since what you're talking is not related to API, please tell devs this:

    Getting attachment is fine.

    curl --request GET --url https://www.meistertask.com/api/tasks/<taskId>/attachments --header "Authorization: Bearer <pea>" --header "accept: application/json" --header "content-type: application/json"

    Please replace <taskId> and <pea> to whatever appropriate. The result is 200 with correct JSON. But POST never works. This is minimal curl query you can test (I modified the exmaple on the doc):

    curl --request POST --url https://www.meistertask.com/api/tasks/<taskId>/attachments --header "Authorization: Bearer <pea>" --header "accept: application/json" --header "content-type: application/json" --data "{ ""local"": ""data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII""}"

    The data used is one of the smallest b64 images ( https://gist.github.com/ondrek/7413434 ). The result is 400 with error message: "Parameter local should be of type ActionDispatch::Http::UploadedFile!"

    Additionally, I really want you to add a feature allowing use of URL instead of local file.

  • Miša Hennin
    Miša Hennin Admin, MeisterLobster, EN Business Posts: 1,676 Community Admin

    Hi @sangbok lee,

    I have forwarded your request to support. They will be able to take a closer look and will be in contact with you via email shortly.

    If you'd like to submit a feature request, please head over to the feature request category and post your idea there.

    Best,

    Miša