This topic was automatically generated from Slack. You can find the original thread here.
Kyle Schiess : Can I make a JSON POST request from pipdream’s node.js ?
This topic was automatically generated from Slack. You can find the original thread here.
Kyle Schiess : Can I make a JSON POST request from pipdream’s node.js ?
Dylan Sather (Pipedream) : Hi , yes, take a look at https://docs.pipedream.com/workflows/steps/code/nodejs/http-requests/#send-a-post-request-to-submit-data
Dylan Sather (Pipedream) : that’s just an example. You can require
any npm package from a Node.js code step, so you could use another HTTP client, if you’d like
Kyle Schiess : can you not use the request lib?
Dylan Sather (Pipedream) : The request
package has been deprecated -request - npm - so I’d actually recommend not using it if you have alternatives.
Part of the issue with the request
library is that it doesn’t support a Promise-based API, and on Pipedream, all code must be run synchronously, so you can’t use callbacks in the manner that request
and other libraries expect.
Dylan Sather (Pipedream) : got
, node-fetch
and other packages should work
Dylan Sather (Pipedream) : here’s a little more information on the synchronous code requirement if it helps: https://docs.pipedream.com/workflows/steps/code/#running-asynchronous-code
Kyle Schiess : I guess the reason I ask about request is that I keep getting a 400 error when I try to post to another app’s API (Phantombuster). Is this when I’d need to use the httpsProxyAgent?
Dylan Sather (Pipedream) : Probably not in this case. A 400 error usually suggests the data you’re passing isn’t in the correct format. Do you see any more-specific error message getting returned from Phantombuster, or do their docs suggest what the 400 error might be related to?