1
0
-1

When I call v2 API with the action addPictureUrl with three images, I get three recordMessages in the result set. There is nothing to differentiate between the three IDs that are returned. JSON does not guarantee order, so I can't simply rely on the order of the images in the recordMessages array. 

In my example, all of the pictures are associated with a single animal; however, since I'm providing the animalID for each pictureUrl, this could be three different animals - which would further complicate the mapping of returned images to animals (and the picture order on the animal).

It seems that, if I care about this mapping, I need to limit the addition of pictures to one per API call.

Here's the API call:

{
    "token":"{{token}}",
    "tokenHash":"{{tokenHash}}",
    "objectType":"animals",
    "objectAction":"addPictureUrl",
    "values":
    [
        {
            "animalID":"{{animalID}}",
            "pictureUrl":"https://via.placeholder.com/150"
        },
        {
            "animalID":"{{animalID}}",
            "pictureUrl":"https://via.placeholder.com/200"
        },
        {
            "animalID":"{{animalID}}",
            "pictureUrl":"https://via.placeholder.com/250"
        }
    ]
}

and the result:

{
    "status": "ok",
    "messages": {
        "generalMessages": [],
        "recordMessages": [
            {
                "status": "ok",
                "ID": 81778946,
                "messageID": "1003",
                "messageCriticality": "info",
                "messageText": "Successfully saved the record."
            },
            {
                "status": "ok",
                "ID": 81778947,
                "messageID": "1003",
                "messageCriticality": "info",
                "messageText": "Successfully saved the record."
            },
            {
                "status": "ok",
                "ID": 81778948,
                "messageID": "1003",
                "messageCriticality": "info",
                "messageText": "Successfully saved the record."
            }
        ]
    },
    "foundRows": 0,
    "data": []
}
    CommentAdd your comment...

    1 answer

    1.  
      1
      0
      -1

      Ken Cline Thank you for your question. I believe you are correct that you would need to isolate your pictures by animal and not mix animals within one call to the addPictureUrl API. I don't believe there is a better way to handle this issue at this time - and I don't believe it's something we can improve on with this version of the API.

      However, we expect with the v5 API which should have authenticated/private endpoints available soon, you will have several options, but it may still be advisable to make separate calls by animal.

      I also wanted to mention that you might consider posting questions and comments to our Google Group for the API developers here: https://groups.google.com/a/rescuegroups.org/g/apidev

        CommentAdd your comment...