Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

InsertFromURL CURL formatting errors?

Featured Replies

I have a simple API endpoint I have working in both Postman and PAW that uses cURL. It does not work when I use insert form URL and paste into the CURL section. I dont understand why you cant just PASTE the text from Postman or PAW into the CURL Options WITHOUT having to do some convoluted text string manipulation. Any ideas on how to do this easily without PLUGINS or TEXT MANIPULATION?  Shocking that FMP18 doesnt support this natively.

Here is what works in POSTMAN and PAW:

ENDPOINT: https://stevesie.com/cloud/api/v1/endpoints/e7762587-1426-47ac-b5d5-d9b2836ec89b/executions

CURL: 

curl --location --request POST 'https://stevesie.com/cloud/api/v1/endpoints/e7762587-1426-47ac-b5d5-d9b2836ec89b/executions' \
--header 'Token: 3138c6bb-6623-4bef-9da0-c61793a0d117' \
--header 'Content-Type: application/json' \
--data-raw '{"inputs":{"neighborhood_id":"","ne_lat":"","ne_lng":"","property_type_id":"","sw_lat":"","sw_lng":"","checkin_date":"2020-03-10","checkout_date":"2020-03-21","location":"Palo Alto, CA","price_max":"","price_min":"","superhost_only":"","currency":"","limit":"","offset":"","airbnb_api_key":""},"proxy":{"type":"shared","location":"nyc"},"format":"json"}'

 

 

You don't have to do convoluted text manipulation at all, once you have one working example in FM you'll find it very easy.

A couple of immediate thoughts:

- The insert from URL has different sections, one is where you put the URL to hit, so you don't put that into the actual cURL options in FM

- Postman and others use "\" as a line continuation device to make the text readable.  It is not part of cURL at all.  And "\" carries a specific meaning in FM so don't use it.

- create the Json you need to send in a variable ahead of using "insert from URL" so that in your FM cURL options you can just use "-d @$json".  That saves you from having to do a bunch of pesky quote escaping

  • Author

Thanks for the suggestion but still having trouble with saying it cant find the specified table?

A) I think you mean I create a Insert from URL step and put the destination URL end point which is:
https://stevesie.com/cloud/api/v1/endpoints/e7762587-1426-47ac-b5d5-d9b2836ec89b/executions

B) Where in the Insert from URL step do I put the headers which from Postman look like this?
--header 'Token: 3138c6bb-6623-4bef-9da0-c61793a0d117'\
--header 'Content-Type: application/json' --data-raw\

What do I do to get rid of the "\"?
If I paste the POSTMAN curl into the FMP calculation step and DELETE the "\" it still says it cant find the specified table.  Is there a way to paste text into a calc function inside of quotes or brackets to keep FM from doing this?

C) I also think you mean I first  need to create a Set Variable ($json) before the insertFromURL step and then I paste the just JSON into the value field.  I would then put this in the specify cURL options of the InsertFromURL assuming without the " ":
"-d @$json" 

D) When I paste the just the JSON from POSTMAN in to the value field of the variable and try to save it says it cant find the specified table?
{"inputs":{"neighborhood_id":"","ne_lat":"","ne_lng":"","property_type_id":"","sw_lat":"","sw_lng":"","checkin_date":"2020-03-10","checkout_date":"2020-03-21","location":"Palo Alto, CA","price_max":"","price_min":"","superhost_only":"","currency":"","limit":"","offset":"","airbnb_api_key":""},"proxy":{"type":"shared","location":"nyc"},"format":"json"}

 

starting backwards:

D)

you don't paste the text from the json in a Set Variable, you use the FM json functions to build your json.  I'm assuming that since you're doing this from inside FM that you will be building the json based on FM.  So use the JsonSetElement() function

C)

correct

A)

You get rid of the "\" but not using them as line continuation.  You keep them where you need to escape the quote characters

Your cURL options string would look like this and you put them in the cURL options section of the "insert from URL" script step

-X POST --header \"Token: 3138c6bb-6623-4bef-9da0-c61793a0d117\" --header \"Content-Type: application/json\" -d @$json

  • Author

OK I must be an idiot but if I copy and paste your curl option string in orange exactly like you have it i still get this error

image.thumb.png.cf2f9af9980254721e78f013d952ea8a.png

put a quote at the start and one at the end

  • Author

OK I think Im almost there.  I have a new setVariable as $json.  For the value/calc step I know i need to use this:
JSONSetElement ( json ; keyOrIndexOrPath ; value ; type )

What do i need to put in each of those 4 parameters to use this JSON:
{"inputs":{"neighborhood_id":"","ne_lat":"","ne_lng":"","property_type_id":"","sw_lat":"","sw_lng":"","checkin_date":"2020-03-10","checkout_date":"2020-03-21","location":"Palo Alto, CA","price_max":"","price_min":"","superhost_only":"","currency":"","limit":"","offset":"","airbnb_api_key":""},"proxy":{"type":"shared","location":"nyc"},"format":"json"}


 

If you already have a valid JSON document, then you do not need to use any of the JSON functions. Simply set the variable to the text of the JSON. If the text is in a field, then just set the variable to the field. If you want to hardcode it in a calculation, you need to set the variable to the escaped version, which in your example would be:

"{\"inputs\":{\"neighborhood_id\":\"\",\"ne_lat\":\"\",\"ne_lng\":\"\",\"property_type_id\":\"\",\"sw_lat\":\"\",\"sw_lng\":\"\",\"checkin_date\":\"2020-03-10\",\"checkout_date\":\"2020-03-21\",\"location\":\"Palo Alto, CA\",\"price_max\":\"\",\"price_min\":\"\",\"superhost_only\":\"\",\"currency\":\"\",\"limit\":\"\",\"offset\":\"\",\"airbnb_api_key\":\"\"},\"proxy\":{\"type\":\"shared\",\"location\":\"nyc\"},\"format\":\"json\"}"

Hint: use the Quote() function to get the escaped text to be used in a calculation formula.

JSONSetElement ( "{}" ;

[ "inputs.neighborhood_id" ; "some value" ; jsonstring ] ;

[ "inputs.ne_lat" ; "some value" ; jsonstring ] ;

... keep going here with all the input keys ...

[ "proxy.type" ; "shared" ; jsonstring ] ;

[ "proxy.location" ; "nyc" ; jsonstring ] ;

[ "format" ; "json" ; jsonstring ]

)

  • Author

THANK YOU!!!!!

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.