August 12, 20205 yr 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,
August 12, 20205 yr 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
August 12, 20205 yr 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\"}"
August 13, 20205 yr 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.
August 26, 20205 yr 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
August 27, 20205 yr 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.
August 27, 20205 yr 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.
September 4, 20205 yr 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