What could be causing the "Expected ',' or '}' after property value in JSON at position 125" error message when executing a custom API call in Pipedream?

This topic was automatically generated from Slack. You can find the original thread here.

Hello!

I’m fairly familiar with Pipedream and have built some cool things with it but I’m stuck on a perplexing error message.

You can watch the screen recording I shared with the support team here. I’m on the free tier, so I don’t have any hopes of getting that answered soon. :upside_down_face:

I’m attempting to execute a “custom” API call in PD (it isn’t custom to the API I’m calling, but standard).

Here’s the code:

import { axios } from "@pipedream/platform"
/** credentials here **/

let field_payload = JSON.stringify(
    {
      field_id: "99ae89a6-cfff-4729-aae1-620b9ef3dc25",
      operator: "=",
      value: "86b010jfw"
    },
  );

export default defineComponent({
  props: {
    clickup: {
      type: "app",
      app: "clickup",
    }
  },

  async run({steps, $}) {
    return await axios($, {
      url: `https://api.clickup.com/api/v2/team/${team_Id}/task?space_ids[]=${space_Ids}&custom_fields=${field_payload}`,
      headers: {
        "content-type": `application/json`,
        "Authorization": `${this.clickup.$auth.oauth_access_token}`,
      },
    })
  },
})

The pipedream error I keep getting is Expected ',' or '}' after property value in JSON at position 125

When testing the code above with out the &custom_fields=${field_payload} parameter, the API request works fine.In Postman & with cURL, the API call works fine.

Does anyone have any input on resolving this error message? Again, see screen recording above for visuals.

Many, many thanks!

Can you double check that the custom_fields query param accepts JSON? That seems like a non-standard implementation. Usually JSON is accepted as part of the body of a POST request

The Axios wrapper that Pipedream provides is causing the error; if you use the Axios package instead, it will work as normal.

Hi, !

Thanks for the insight! I’ve revised the code to use the package directly instead. I do not receive the error any longer, so thank you!

At the moment, I’m wrestling with a timeout error produced from using **import** axios **from** "axios"; as opposed to the original means above.

Do you happen to know why my call is consistently timing out after this change? There is no issue making the API call via Postman with axios or via cURL. The server is sound.

Thanks!

Unfortunately, I haven’t received any timeout errors while testing so I wouldn’t really know.

, I figured out the original way of doing it. encodeURIComponent() is needed around the JSON object, as the Axios wrapper pipedream uses decodeURIComponent to clean up the URL query params.

let field_payload = encodeURIComponent(JSON.stringify(
    {
      field_id: "99ae89a6-cfff-4729-aae1-620b9ef3dc25",
      operator: "=",
      value: "86b010jfw"
    },
  ));

You can use either solution, but if the timeout error persists, I’m not sure what is causing that.

IT LIVES!!! thank you!!

Can you please share how you came to this conclusion? Obviously, I need to RTFM about encodeURIComponent , but I’m dying to know how you realized this.

https://github.com/PipedreamHQ/pipedream/blob/master/platform/lib/axios.ts#L16…L38
This is the axios wrapper for pipedream and the highlighted lines is the function which caused the error as it needed the query parameters to be in this format field_id=99ae89a6-cfff-4729-aae1-620b9ef3dc25&operator==&value=86b010jfwso it can turn it into a json object and put into the params object array but it got a json object already. Lines 25 to 29 is where it would always fail as it was given a JSON object and not a string as it requires causing an error.

Nice find !

Let me check with the team to ask why this modification was included.

Brilliant, . Thank you SO much.