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.

cURL Options in Insert from URL Script Step

Featured Replies

I'm trying to use an API command using Insert from URL with cURL options, this is what I have in the cURL options:

curl -v -u <user>:<password> --header "Content-Type: application/json" -d '{"type": "typetest", "priority": 1, "description": "desctest", "subject": "subjecttest", "email": "[email protected]", "email_config_id":67 }' -X POST 'https://subdomain.freshdesk.com/api/v2/tickets/outbound_email'

As described in the API documentation: https://developer.freshdesk.com/api/#create_outbound_email

The command works well in the command line but not when executed through Insert from URL, do you know why? is there an error I can't spot?

Thank you,

  • Author

I've found the problem: json data must be formatted with JSONFormatElement, so the cURL option in FM must be:

curl -v -u <user>:<password> --header "Content-Type: application/json" --data @$json_parameters  -X POST

Where $json_parameters is a FM variable that stores the value of JSONFormatElement

37 minutes ago, naio said:

json data must be formatted with JSONFormatElement

I doubt that is the case. JSON data is equally valid whether formatted or not. Unless your API uses a non-conforming parser, formatting should make no difference.

Using another API, i am able to post JSON data using either one of these cURL options:

--header "Content-type: application/json" -d {"name":"Adam","job":"Developer"}
--header "Content-type: application/json" -d @$postData

where the $postData variable contains the same JSON.
 

Note the absence of single quotes in the first option. Of course, if you want to enter this directly into the Insert From URL[] script step's 'Specify cURL options' calculation window, you will need to escape it properly as:

"--header \"Content-type: application/json\" -d {\"name\":\"Adam\",\"job\":\"Developer\"}"

 

  • Author

I've tried with my non-formatted json data (as in my first post) but now excluding the single quotes around it and it doesn't work, maybe the API doesn't use a non-conforming parser, I can't tell.

For debugging this I used the very useful tool offered by Mike Duncan here: https://www.soliantconsulting.com/blog/filemaker-rest/ and I see FM is not sending non-formatted data.

  • 2 weeks later...

Good morning.  Thank you both again for your assistance with this.

What ended up working was formatting the data command with:

JSONSetElement ( "{}" ; ...     rather than
JSONSetElement ( "" ; ...

From what I've seen in other examples when reading forums, I have seen them used interchangeably with the same results. As the resulting text appeared the same whenI ran it (its quite robust) - go figure. Anyway, it's working now and I'm happy.  Thank you for your guidance. :)

Greg

36 minutes ago, Greg Hains said:

I have seen them used interchangeably with the same results

Well, if the results are the same - and I believe they are - then it cannot make any difference, can it? Unless you believe in magic.

 

Haha - I believe in magic, but want NO part of it when doing code. Prefer consistency. :)
I don't understand either, but as the output code was the same it HAS to have the same result.

Thanks Comment.

  • 2 weeks later...
  • Author

Again, another picky API:

https://developers.sendinblue.com/reference#updatecontact

With this PUT command, I can't find the way to send the --data parameter to the server. 

These are the cURL options I'm using:

--request PUT \
--header \"accept: application/json\" \
--header \"api-key: " & $$my_api_key & "\" \
--header \"content-type: application/json\" \
--data @$parametre

I've tried to set the $parametre variable to:

JSONSetElement ( "{}" ; "emailBlacklisted" ; True ; JSONBoolean )

JSONFormatElements ( "{\"emailBlacklisted\":true}" )

and simply:

"{\"emailBlacklisted\":true}"

none of these options satisfies the server, which always returns the following error message:

{"code":"bad_request","message":"Input must be a valid JSON object"}

There may be something wrong in the syntax of the --data parameter but I can't find what it is. I've also tried to quote the parameter:

with single quotes --data '@$parametre'

and escaped double quotes --data \"@$parametre\"

None of this seems to work. I'm completely lost...

 

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.