Legacy Dev Forum Posts

 View Only

Sign Up

API response is array of strings, data action returns "unsupported media"

  • 1.  API response is array of strings, data action returns "unsupported media"

    Posted 06-05-2025 18:44

    Nebojsa_Radovanovic | 2022-12-26 15:44:32 UTC | #1

    Hi all, opened a ticket regarding this as well. Basically our client is using NorthStar API, which we need to query using data actions to retrieve account IDs, which are returned as an array of strings (most of the time, only one array element is returned) This is a full response example, obtained in postman: [ "MTIzMTIzQEAz" ]

    But i can't get GC data actions to return anything other than the Unsupported Media response, i've tried multiple data actions contract combinations but i'm not getting any valid response. here's my output contract that should be working: { "type": "array", "items": { "title": "Item 1", "type": "string" } }

    Tried adding Accept and Content-Type headers with "application/json" as value., as well as Transfer-Encoding "buffered", but that didn't help. Any ideas? Are arrays of strings really not supported as GC data action outputs?


    Jason_Mathison | 2022-12-26 21:25:55 UTC | #2

    It would be really helpful to post the complete error message that you are getting in test mode so that there is more context to the error. In general that error means that the remote endpoint is returning a "Content-Type" header of some type other than "application/json".

    --Jason


    Nebojsa_Radovanovic | 2022-12-26 21:47:57 UTC | #3

    Hey, here's the error

    { "message": "The server encountered an unexpected condition which prevented it from fulfilling the request.", "code": "internal.server.error", "status": 500, "messageParams": {}, "contextId": "c7bd177b-ac38-4cc6-913c-95c657ca23fc", "details": [ { "errorCode": "ACTION.REMOTEENDPOINT" } ], "errors": [ { "message": "REST call for action execute failed. Message: Request to backend service failed. Response from web service: <html><head><title>Error</title></head><body>Unsupported Media Type</body></html> [c7bd177b-ac38-4cc6-913c-95c657ca23fc]", "code": "INTERNALSERVER_ERROR", "status": 415, "messageParams": {}, "details": [], "errors": [] } ] }

    Sorry, should have posted it earlier. As far as the response headers go, i've checked it via postman, Content-Type is "application/json".


    Jason_Mathison | 2022-12-27 04:42:17 UTC | #4

    Thank you for the error, that helps clear up the situation!

    The error is saying that the remote endpoint is returning the error. When you test in postman are you setting the request content-type header to "application-json"? Or is your data action configured to send a content-type header? Finally, which region are you testing in, so that I can look at the logs on our side?

    --Jason


    Nebojsa_Radovanovic | 2022-12-27 10:03:16 UTC | #5

    When testing from postman, i'm only sending the authorization header, and receiving these headers in the response: Nothing changes in postman or data actions, if i add the Accept and Content-Type headers with "application/json" value to my request.

    The data action testing was performed from the client's org in the Canada region.


    Jason_Mathison | 2022-12-27 18:26:27 UTC | #6

    Try adding a content-type header of "application-json" to the request in postman to see if that reproduces the error. If so, you might be able to experiment with different content-type headers in your data action, or ask the vendor what content types they accept.


    Nebojsa_Radovanovic | 2022-12-28 11:44:53 UTC | #7

    Adding the content-type header to postman did reproduce the error in postman, looks like adding that header in the request changed the Content-Type header in the response, now it's "text/html;charset=UTF-8". But no matter the combination of headers, i still cant get it to work in data actions, even though the response in one of the cases where no headers are enabled except authorization, should have "application/json" as the content-type.


    Nebojsa_Radovanovic | 2022-12-28 15:31:50 UTC | #8

    Hey Jason, tried this some more, it looks like adding the header Content-Type "/" solves this, as well as some response template trickery, as it seems data actions are appending Content-Type "application/json" by default, and it is causing the issue with this vendor (since they are responding with a text/html response in that case).

    Thank you for your help


    Jason_Mathison | 2023-01-03 15:56:32 UTC | #9

    We set the content type to application/JSON by default since our service is only designed to exchange JSON with whatever endpoint it is talking to. Your description makes it sound like the endpoint is not properly handling the correct content type, but please speak up if it seems like Data Actions should be behaving differently.

    --Jason


    system | 2023-02-03 15:57:19 UTC | #10

    This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.


    This post was migrated from the old Developer Forum.

    ref: 17765