cURL to blocks automatic generator

Looks like it is one of those urls that is expecting a web page (the base url works in a webview). You might be able to capture the response in a webviewstring and return this to your app.

can you please provide me some blocks please

waiting from last 2 hours :slightly_frowning_face: :slightly_frowning_face: :slightly_frowning_face:

Your curl command does not work in my terminal?

That sort of comment will not encourage people to help you.....

2 Likes

i tried in

Run Curl Commands Online (reqbin.com)

and also in 2 android apps and its working fine...

I believe I understand what is going on. You site is returning the data in a compressed format. If I use the --compressed option in your curl command it returns the data in my terminal (linux).

Remove:

-H "accept-encoding:gzip"

from your headers, and it should work.

ref

you are really genius man...

thanks a lot...

its working now

I see you also asked on Kodular - you should advise that you got your solution on the AI2 community :wink:

Ya... sure...

Hi, I wasnt sure if I should post in here or start a new question, as its not been updated recently.
I've been trying this and don't get any successful results.
This is the input which is an example given on the ORS website and gives results correct using Git Bash

curl -X POST \
  'https://api.openrouteservice.org/v2/directions/driving-car' \
  -H 'Content-Type: application/json; charset=utf-8' \
  -H 'Accept: application/json, application/geo+json, application/gpx+xml, img/png; charset=utf-8' \
  -H 'Authorization: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' \
  -d '{"coordinates":[[8.681495,49.41461],[8.686507,49.41943],[8.687872,49.420318]]}'type or paste code here

this is the output from cURL to blocks -

Which gives error.

{"error":{"code":2002,"message":"Parameter 'coordinates' has incorrect value or format."},"info":{"engine":{"build_date":"2024-03-21T13:55:54Z","version":"8.0.0"},"timestamp":1715408546132}}

I've tried various things including the "join" method mentioned above.
Any ideas ?

Put your coordinates in list blocks?

This gives the same result

It looks to be a list of lists...

Same result

{"error":{"code":2002,"message":"Parameter 'coordinates' has incorrect value or format."},"info":{"engine":{"build_date":"2024-03-21T13:55:54Z","version":"8.0.0"},"timestamp":1715416191406}}

Not quite...

:face_with_hand_over_mouth: I'm so sorry I make it so difficult for you to show me the way lol

Its obvious to see the difference when using "do it".
I do appreciate you guy's trying to educate me although its hard going for you.

There is a Web block to turn a structure into JSON text.

JSONTextEncode ?

Did your last effort work ?

yes, sorry, once you pointed out the easiest way to view the structure it all made sense and worked fine !

I used a tip from one of your replies to someone else's question to convert text to number as and it took me a little while to realise that the OSR API takes coordinates in longitude, latitude order. which now works fine.
image

I was looking for distance and duration only not directions, which are returned in meters and seconds which I have converted ok for my needs mathematically but out of curiosity I had a play around with trying to set the output to miles.
Changing this on the "API playground" adds "units":"mi" to the data line of the curl

-d '{"coordinates":[[-2.091320179410226,57.182416616039184],[-2.0937750440109335,57.14995786137407]],"units":"m"}'

But I couldnt find a way to add it to the line without turning it back into strings.
For my needs it's not important but curiosity makes me wonder how or if it would be possible to add the text without the extra "'s.