File attachments for contacts - API v2.2

Hi there,

Thanks for the new API and the docs, they are very helpful!

I am looking at the endpoint POST /Contacts/{id}/FileAttachments and I am having trouble getting a successful response. I have tried a number of parameter combinations but only get 400 status codes back.

I have tried this JSON object as the request body:
{
"file": "...base64 encoded file data..."
}

What am I missing here?

Thanks for your help,
Dominic
0

Comments

3 comments
  • Official comment

    Dominic,

    Thanks for the question. This looks like a problem with the documentation.

    The POST endpoint is expecting a multipart form request. This has been implemented in the Python library, but is not available in the PHP library (this library was written by one of our customers). I would suggest opening an issue on the Github repo for the library. 

    If the developer is not able to add this, you can find some good examples of how to create multi-part form requests on stack overflow (or use the Python library's upload() method as an example and port that into PHP).

    If you have any other questions, let me know.

    Thanks,

    Brian McConnell

    Insightly Engineering Team

    Comment actions Permalink
  • Thanks Brian, that is helpful.

    I have looked into the Insightly Python library,as you suggested and I have implemented my own PHP version of the function "upload"

    https://github.com/Insightly/insightly-python/blob/v2.2/insightly.py#L601

    I have also found that adding additional fields (such as file_category_id) as separate multipart post parameters worked a treat!

    Thanks again for your help!

    Dominic

    0
    Comment actions Permalink
  • Hi Dominic,

    I've updated the Python library to support Python version 3.x, in addition to 2.7, so you should be able to use it with either version now.

    Brian

    0
    Comment actions Permalink

Please sign in to leave a comment.