โ10-12-2023 07:24 AM
Hi, I'm trying to send an HTTP request to an API endpoint using the Workato HTTP app "Send request via HTTP". The endpoint is expecting a field name of "First Name" (with a space) but it appears when creating the field name Workato does not allow spaces in the field names. I can only use snake case, such as "FirstName" or "First_Name". When the endpoint receives it in either format, I think it is interpreting it as "FirstName" or "First_Name" rather than the anticipated "First Name" and as a result does not accept the associated value as expected. And yes, the same thing happens with the Last Name. Other one-word field names are not having this issue.
Solved! Go to Solution.
โ10-12-2023 10:30 AM
If you're referring to the response schema, I can't find a way around this issue directly in the HTTP action. Usually, you can use a JSON sample to work around this blocker, but when using a JSON sample with "first name", Workato automatically changes it to "first_name".
However, there are a couple things that do work...
First, you can access the key directly with bracket notation. This is a little clunky, but it works.
This message imitates the API response:
And then you can access it like this:
Output:
Second, (definitely the better option) you can feed a sample JSON with spaces into the JSON parser, and it will parse it without issue.
It still replaces the spaces with underscores, but this action provides data pills that retain the expected value.
Output schema:
So if I do this:
I get this:
Hope this helps!
โ10-18-2023 05:17 AM
Hi gary1,
Thank you for the break down. I think I see where the confusion is. Your explanation is for how to handle the HTTP response but my issue is with the HTTP request.
โ10-18-2023 01:05 PM - edited โ10-18-2023 01:39 PM
Got it, thanks for all of the info. I think I have this figured out.
If you create the request body by providing a JSON sample, you can bypass this blocker. I tested this out using a recipe with an HTTP action using a multi-part form to make a POST call to an API endpoint, and then reviewing how the payload was received.
First, on the request body schema of the HTTP action I clicked "Use JSON" and to provide an example of how I want my payload to be structured:
I entered this:
It created this, which is misleading because it added the underscore to the label:
However, if you look at the schema, it has a details.real_name value of "test test" which is actually how the field gets encoded and sent in the API call:
Next I made an API call to an internal endpoint (with a value of "123").
I logged the message three different ways to be absolutely certain it was retaining the space:
To JSON:
To string:
Raw:
And then I even threw it into the JSON parser to ensure it parsed correctly:
And it did:
This is the way! Hope it gets you where you need to go.