question

neil-joyer10782 avatar image
neil-joyer10782 asked victor-shisterov38 answered

Parameter "attachments" is invalid

We've been using the RC api to post conversations to glip. Some of the posts included images. To implement images, we used the "Attachments" feature outlined here:

https://devcommunity.ringcentral.com/ringcentraldev/topics/new-glip-features-post-attachments-and-th...

It worked great and showed the images inline in chat.

However, a few weeks ago (not exactly sure when), all posts that contain attachments quit working.

I finally got around to debugging and can see that it is because RC/Glip is returning a 400 Bad Request error with the message: "Parameter "attachments" is invalid".


I tried getting a post to go through using the api explorer using attachments and I can't get that to work either.


Did something break with attachments? I'm pretty sure the format of our payloads to the api didn't change.

errors
1 |1500 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

victor-shisterov38 avatar image
victor-shisterov38 answered
Hi Neil, could you please share the full body of your API request?
1 |1500 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

neil-joyer10782 avatar image
neil-joyer10782 answered
Since I was having trouble with the payload generated by my app (even though it didn't change), I tried reproducing via the api explorer and was able to. Here is a simplified version: { "groupId": "191750150", "attachments": [ { "type": "Card", "title": "test", "color": "Black", "allDay": false } ] }
A representation that is closer to what I'm trying to do: { "groupId": "191750150", "attachments": [ { "type": "Card", "title": "test", "color": "Black", "text": "[https://i.imgur.com/gQ3EeN3.gif](https://i.imgur.com/gQ3EeN3.gif)", "imageUri": "https://i.imgur.com/gQ3EeN3.gif", "allDay": false } ] }
1 |1500 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

victor-shisterov38 avatar image
victor-shisterov38 answered
Hi Neil, the problem is with the  color attribute, it should contain Hex color code, like
"color": "#00ff2a"  
The value "Black" was just ignored and now some validation added on the API level. Since Glip API is in Beta now, we may change its behavior from time to time, but we'll improve the process adding all the potential compatibility breakers to the common changelog and adding more self-descriptive error messages. Sorry for inconveniences.
1 |1500 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

neil-joyer10782 avatar image
neil-joyer10782 answered
A couple of comments.
I should have included my exact payload rather than the one I generated using the api explorer. This is my actual payload that was getting denied:
{
    "groupId": "191750150",
    "attachments": [
        {
            "type": "Card",
            "title": "[ https://i.imgur.com/gQ3EeN3.gif](https://i.imgur.com/gQ3EeN3.gif)";,
            "imageUri": " https://i.imgur.com/gQ3EeN3.gif";
        }
    ]
}

This is what I found ended up working:
{
    "groupId": "191750150",
    "attachments": [
        {
            "type": "Card",
            "text": "[ https://i.imgur.com/gQ3EeN3.gif](https://i.imgur.com/gQ3EeN3.gif)";,
            "imageUri": " https://i.imgur.com/gQ3EeN3.gif";
        }
    ]
}

Basically, the title was causing it to fail. Switching that to "text" made it work. However, that used to work. Also, having both "title" and "text" works fine too.

I'll also add that the api reference generates the value "black" for color... which is why it was included in my sample. It would be good if that was updated to be hex because right now you can't get posts to generate since that is a drop down with only invalid values.

I'm unblocked. Thank you.
1 |1500 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

victor-shisterov38 avatar image
victor-shisterov38 answered
Yes, we accidentally changed the  text attribute to be a mandatory one. We'll update the API Reference and the changelog. Thanks for your feedback!
1 |1500 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys