What Can I Do to Make My Pipedream API Reflect the Trade Alert in JSON Format?

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

Tradeview is sending a trade alert via Pipedream webhook in JSON format. I then send the JSON alert to Telegram. I got all this to work. The issue I’m having is I want my Pipedream API to reflect the trade alert in the JSON format. In my trigger, I changed the HTTP Response to Return custom response from your workflow. The export and log display the JSON results I want. When I deployed and did a htts://{my_pipdream_api} in my browser and I got a blank screen. My code is the attachment. Your help is appreciated. help general

Hey , you can return a JSON directly in the response body, no need to stringify it

Not sure if that is the cause, though

Could you follow the steps in this guide: Triggers - Pipedream

Hey , I appreciate the response, but it does the same thing without the stringify and I already looked at that doc. That’s where I started, and I got it print out a “hello world” message in the browser. The hello world was in the export and log just like the JSON object is, but it won’t show the JSON object in the browser. I don’t know what I’m missing. Any other thoughts or suggestions?

@U03K4ERLE68 @UMLT42ZB4

Could you allow support access to your workflow and share the URL here?

There nothing to what I have. Here are the screenshots of the code.

1st screenshot: Trigger configuration
2nd screenshot: Trigger select event & result. So, it received the JSON data via Post command.
3rd screenshot: The Code step results. As you can see the JSON data got export out successfully in JSON object format.

Why it doesn’t show up in my htts://I|https://{my_pipdream_api} is beyond me.

Why it doesn’t show up in my htts://I|https://{my_pipdream_api} is beyond me.
How are you accessing in your browser? Are you just opening the webhook URL in your browser?

Because if so, you are not passing a body to your workflow, so it’ll return an empty body

I’m opening my webhook in my browser. I’m not passing body to workflow? I thought steps.trigger.event.body is passing it.

So, what should be changed or added?

When you launch your web browser and enter the webhook URL into the address bar, the browser initiates a GET request. This request does not include a body. Essentially, it’s a simple request asking the server to send the data for that specific page without submitting any additional data from the client side

can you help explain the difference between opening the URL in the browser and making a POST request with a body using curl or python requests?
Could you also give an example command

Certainly! Opening a URL in a browser and making a POST request with a body using curl or Python’s requests library are fundamentally different operations, primarily in terms of the HTTP method used and the level of interaction with the server. ### Opening a URL in a Browser: - When you open a URL in a browser, you’re typically making a GET request to the server. This request asks the server to send data back to the browser, which is then rendered as a webpage. - GET requests can include parameters in the URL, but they do not have a body. They are mainly used to retrieve data. - The browser handles the request, including setting appropriate headers, managing cookies, and rendering the response. ### Making a POST Request: - A POST request, on the other hand, is used to send data to the server to create/update a resource. This data is sent in the body of the request. - POST requests are used when the amount of data being sent is too large to be passed as query parameters in a GET request or when you want to send data securely. - Unlike opening a URL in a browser, making a POST request typically does not result in a directly viewable page. Instead, it often causes a change on the server (like creating a new record) and returns a response that might be JSON, XML, or some other format. ### Examples: #### Using curl to make a POST request: bash curl --silent -X POST https://postman-echo.com/post -d 'name=Bulbasaur&id=1' This curl command makes a POST request to https://postman-echo.com/post with a body containing name=Bulbasaur&id=1. The --silent option suppresses progress meter but still shows the output. The -X POST specifies that this is a POST request, and -d specifies the data to be sent in the request body. #### Using Python’s requests library to make a POST request: ``` import requests def handler(pd: “pipedream”): url = “https://postman-echo.com/post” data = {“name”: “Bulbasaur”} r = requests.post(url, data=data) print(r.text) print(r.status_code)

Ok thanks… I used up all my tokens today trying to code the POST. It doesn’t know how to try once and stop. It just keeps trying. I added a timeout so hopefully that will keep from using up all my tokens.

Anyway, I now have to wait until tomorrow evening to try. I’ll let you know how it goes. I really appreciate all your help. I’m novice at best at API, CURL, BASH, PYTHON, etc. I’m learning all this on the fly.

For sure! Also feel free to tag Pi and ask questions about coding — he can give out code examples if you ask him

All I’m trying to do is get the Signal line from the BODY of my Pipedream API Trigger to print in JSON format when I type https://my_pipedream_api_key (see attachment). I keep telling myself I know it’s easy to do, take the last steps data and post it to the API.

It’s getting frustrating because if I do any POST command code with an endpoint and it’s not right, it uses all 25 credits in one run. This has happened to me 4 days straight.

PI gives you all these options… you can do it like this or do it like that.

can you copy and paste me exactly what code I can use as a template. I’ve been going down these rabbit holes with curl, bash and python. I don’t know enough about any of them to know which one I should be using. geez…