cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

How to accommodate an HTTP request field name requiring a space

JayMappus
Deputy Chef III
Deputy Chef III

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. 

 
I tried to manually edit the schema but get the following error when I try:

"Oops! Something went wrong
Field name should start with a letter and should not contain spaces or any special characters except `_`
 
Any advice? Maybe I'm off on my analysis of the issue? Thank you for your time and expertise.
 
Settings:
The request content type = Multipart form, Response content type = Text, Encoding = UTF-8
1 ACCEPTED SOLUTION

gary1
Executive Chef III
Executive Chef III

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:

gary1_0-1697131247321.png

And then you can access it like this:

gary1_2-1697131331601.png

Output:

gary1_3-1697131349530.png

Second, (definitely the better option) you can feed a sample JSON with spaces into the JSON parser, and it will parse it without issue.

gary1_4-1697131536850.png

It still replaces the spaces with underscores, but this action provides data pills that retain the expected value.

Output schema:

gary1_5-1697131596541.png

So if I do this:

gary1_7-1697131706823.png

I get this:

gary1_8-1697131717862.png

 

Hope this helps!

View solution in original post

6 REPLIES 6

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. 

 
For the request I need to send a field with a field name of "First Name" so that the endpoint of the request can process it. "First Name" with a space is what the logic of the endpoint is expecting. However, Workato's HTTP request does not accommodate sending the name with a space. Instead it supports "FirstName" and "First_Name". When I use "FirstName" the field name of the request body schema  (image attached) Request body using "FirstName"Request body using "FirstName"in Workato's HTTP appears to separate the First from Name (see image) Screen Shot 2023-10-18 at 8.09.21 AM.pngin the input field name but when received at the webhook endpoint the name appears as "FirstName". Your solution would work if I controlled the logic at the receiving end but I do not and am trying to conform to the endpoint's standard. 
 
Thank you again for your help.

gary1
Executive Chef III
Executive Chef III

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:

gary1_0-1697658795531.png

I entered this:

gary1_1-1697658826068.png

It created this, which is misleading because it added the underscore to the label:

gary1_2-1697658855212.png

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:

gary1_3-1697658891766.png

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:

gary1_4-1697659032034.png

To string:

gary1_5-1697659041082.png

Raw:

gary1_6-1697659047917.png

And then I even threw it into the JSON parser to ensure it parsed correctly:

gary1_7-1697659232517.png

And it did:

gary1_8-1697659241836.png

This is the way! Hope it gets you where you need to go.