[βœ… Solution] Parameters for API Request

What am I doing wrong?

If I put the ID hard into the request, then my workflow works:

But if I want to use a variable from tape (integer), nothing works anymore:

Is there a reason your response variable is different?

The screenshots come from two different workflows, therefore the difference.

I have looked through some of my automations and I have used a number field as it looks like you have without issue I also have some where I have run the following in a calculation in the automation:

parseInt(collected_organisation_field_toggl_ref_decimal_value, 10)

but it looks to me like if it’s a valid number in your variable it should work presumably the API response is not giving you any ideas?

Not being much help, sorry

Thank you for thinking along, @Jason

New Request:

Error of the API Request:

[07:02:58.595] Action execution started.
[07:02:58.903] Action execution failed with error:
{"errorMessage":"Request failed with status code 400","body":null,"statusCode":400,"headers":{"vary":"Origin, Access-Control-Request-Method, Access-Control-Request-Headers","x-content-type-options":"nosniff","x-xss-protection":"1; mode=block","cache-control":"no-cache, no-store, max-age=0, must-revalidate","pragma":"no-cache","expires":"0","x-frame-options":"DENY","content-type":"text/html;charset=utf-8","content-language":"en","content-length":"435","date":"Mon, 22 Jan 2024 06:02:58 GMT","via":"1.1 google","alt-svc":"h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000","connection":"close"}}

Is there a way to put the id=@cv_id into the Request?

@TapeTeam 1:1 the same request structure works in the HTTP request module, but not in the API Request module. Is it possible that this is a bug? :bug:

2 Likes

Just tested passing query parameters via the β€œAPI Request” action without issues. Note, that if your cv_Id variable contains non number characters, special characters etc. it might need to be URL encoded first before you can pass it into the URL.

Could you provide a screenshot of the whole workflow with the working and the non-working action block? And provide me with the info on what value cv_id has?

Passing the value as a request will only be possible if you use a POST or PUT request, where a request body is included.

I send a Integer, this does not work as a variable, but β€œhard” it does.

TWIMC: @Roman and I were able to work out the issue together. The root cause was that the basic token available via the β€œ@” menu also contained the configured prefix of the ID field, yielding a string with a non-numeric prefix. However, the API was expecting to receive the raw ID as a number.

We solved it by declaring a new variable and using the raw ID variable via the workflow code editor:

In above example we have a field called β€œID” inside an app called issues. As the type annotation suggests it is a plain number, while the _formatted variable contains the human readable version including prefix/suffix. Be sure to distinguish those two based on the use case. :bulb: