Sending Integer through JSON in HTTP request piece

{
“custom_fields”: {
“cf_date”: “{{step_2[‘assessmentCompletedDateTime’]}}”,
“cf_url”: “{{step_2[‘descriptiveReportPageUrl’]}}”,
“cf_job_title”: “{{step_2[‘associatedPositionTitle’]}}”,
“cf_scoring_method”: “{{step_2[‘scoringMethod’]}}”,
“cf_pattern”: {{step_3[1]}},
“cf_ssc”: 65,
“cf_scsc”: 30,
“cf_sss”: 28
}

}

When using data from previous steps, it does not allow me to post the data without quotation marks, which is required for integer.

In line 15, you should add add cf_pattern between double quotes, If there is single variable It will be similar to original data type It was.

You can also write JS function inside {{ }}

So you can also do the following "{{Number(step_3[1])}}"

Edit: fixed the parenthesis error below

To be clear, adding the JS function {{ }} will import the data from previous step without quotes?

What does Number do? I noticed there was no closing paranthesis, is that necessary or an error?

Hi @NotMy1RealName

Yes Correct!

You can test with try to use “Data Mapper Piece” → and press Test to see the actual output, and thank you I have fixed the snippet.

Number is to change the type to Number in case it wasn’t a number but a text.

1 Like

Thank you for your code but it still doesn’t work.

I have tried parsing the result using data mapper and code but the problem is in the double quotes. The URL I am posting to needs the data without the double quotes to recognize it as a number. The http piece gives me an invalid json error if I don’t include the double quotes.

I also apologize for the multiple posts, but it does not allow me to post more than one screenshot.

The server api JSON validator is giving an issue where it doesn’t allow any data to be sent without using quotation marks “”. I tried it with number{{ and directly and it still gives the same issue.


this is the output using data step

I also tried this but it did not work

2 Likes

Did you try to put the numbers with double quotes?

“20”

Hello, could you please show use the ssc value in step_8 ? maybe the value is a float and you need to make it an integer instead.

If I put 30 in double quotes it gives me the same error

The output in the previous step is just a number

sorry, but I don’t see an “ssc” value there.


It comes from the circled mscore value

I have a similar problem, followed the thread but cannot seem to fix it.
image

It returns an empty list of and no categories are added to the post:
“categories”: ,

Categoy IDs should be an integer list, such as [4, 23]:
image

Inserting it just as a normal JSON results in following Error:
image

Any hints on how to pass an integer list into JSON stemming from a variable in ActivePieces?
Thanks!

Hi @JulianJay ,

You are working with wordpress right? try it manually first but I think your solution is adding a space between the comma and the new number.
“19, 22” instead of together. no need for hooks either! just the numbers seprates and a comma and a space.

KR Bram

Hi @SCH_Hiring,

it looks like there is something wrong with you mapping, could you please double check you have mapped the correct fields?

If so, could you try to replace the mapped field with the number you are after to see if that works?

btw if you could record something that would be great.

Just trying to see I can help you further.

KR bram

Hi Bram!
Thanks for your swift reply!
Exactly, its the https://WP/wp-json/wp/v2/posts/post endpoint.

The space between the coma does not seem to play a role. I tried it manually. With or without - it assigns the correct categories:

So again to sum up:
“categories”: “{{step_20}}” results in

while using

results in assigning 0 categories to the post:
image

Hi @JulianJay

As ealier suggested, remove the block hooks

Just between apostrophes: “19, 21” and not [19, 21]

This should work, let me know the outcome

KR bram

Ah okay thanks!
Now I got it.
Using it as such works!
image

Thanks- an easy fix.

Thanks for trying to help.

It did not work for me, so I used node.js in a code piece instead.