# Insert from URL to Revolut APi - not working from FileMaker

**URL:** <https://the.fmsoup.org/t/insert-from-url-to-revolut-api-not-working-from-filemaker/4104>\
**Category:** Floating Topics\
**Tags:** scripting\
**Created:** [April 28, 2024, 5:21pm UTC](https://the.fmsoup.org/t/insert-from-url-to-revolut-api-not-working-from-filemaker/4104 "2024-04-28T17:21:30Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anatole](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/anatole/32/368_2.png) [@Anatole](https://the.fmsoup.org/u/Anatole)\
**Post date:** [April 28, 2024, 5:21pm UTC](https://the.fmsoup.org/t/insert-from-url-to-revolut-api-not-working-from-filemaker/4104/1 "2024-04-28T17:21:30Z")

</div>

I would like to be able to trigger payment orders through the Revolut Merchant API from FileMaker. I have the merchant account set up and have a simple working code that triggers a new payment order on the account (see below). This works just fine from Postman and Terminal, but when I run this from an Insert from URL script set in Filemaker, I simply get back '404 Not Found' in the result.

```auto
curl --location 'https://merchant.revolut.com/api/orders' \
--header 'Revolut-Api-Version: 2023-09-01' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <<APIkey>>' \
--data '{
"amount": 10000,
"currency": "GBP"
}'

```

**FileMaker Scripting:**  
Set Variable $json [```  
JSONSetElement ("";  
["amount"; 60000; JSONNumber];  
["currency"; "EUR"; JSONString]  
)

```auto

Set Variable cURL [

```

Substitute (  
List (  
"-X POST";  
"-L " & Quote( "[https://merchant.revolut.com/api/orders](https://merchant.revolut.com/api/orders)" );  
"-H " & Quote( "Revolut-Api-Version: 2023-09-01" );  
"-H " & Quote( "Accept: application/json" );  
"-H " & Quote( "Content-Type: application/json" );  
"-H " & Quote( "Authorization: Bearer {apikey}" );  
"-d @$json" );  
["{apikey}"; $secretKey])

```auto

Insert using URL [Select ; With dialog: Off ; Target: $result ; $url ; cURL options: cURL] 

I have tried numerous variations and even tried accessing other APIs with similar scripting with success. But I just can't get the Revolut API to play if I script it from FileMaker. 

Any ideas?

P.s. I have no idea how to use --trace - is it possible to see what is actually being posted by FileMaker?
```

---

<div class="post-metadata">

**Author:** ![Malcolm](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/malcolm/32/196_2.png) [@Malcolm](https://the.fmsoup.org/u/Malcolm)\
**Post date:** [April 28, 2024, 6:39pm UTC](https://the.fmsoup.org/t/insert-from-url-to-revolut-api-not-working-from-filemaker/4104/2 "2024-04-28T18:39:32Z")

</div>

Try putting the location into the `Specify URL` field.

`Insert from URL [Select ; With dialog: Off ; Target: $result ; "https://merchant.revolut.com/api/orders" ; cURL options:]`

where the cURL options look like this.

```auto
List (
"-X POST";
"-H Revolut-Api-Version: " & Quote( "2023-09-01" );
"-H Accept: " & Quote( "application/json" );
"-H Content-Type: " & Quote( "application/json" );
"-H Authorization: " & Quote( "Bearer " & $secretKey );
"-d @$json" 
)

```

---

<div class="post-metadata">

**Author:** ![Anatole](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/anatole/32/368_2.png) [@Anatole](https://the.fmsoup.org/u/Anatole)\
**Post date:** [April 28, 2024, 10:14pm UTC](https://the.fmsoup.org/t/insert-from-url-to-revolut-api-not-working-from-filemaker/4104/3 "2024-04-28T22:14:52Z")

</div>

Thanks so much for your reply - I wrote it that way to begin with, but that doesn't work either.

---

<div class="post-metadata">

**Author:** ![skywillmott](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@skywillmott](https://the.fmsoup.org/u/skywillmott)\
**Post date:** [April 29, 2024, 5:59am UTC](https://the.fmsoup.org/t/insert-from-url-to-revolut-api-not-working-from-filemaker/4104/4 "2024-04-29T05:59:54Z")

</div>

Malcolm is correct that the URL should be entered into the 'Specify URL' option of the Insert from URL script step rather than in the cURL Options. However, your use of the List function in your cURL options calculation results in the each cURL option/header being on a separate line numbers, whereas the cURL options should be a single line.

So instead of:

```auto
-X POST
-H "Revolut-Api-Version: 2023-09-01"
-H "Accept: application/json"
-H "Content-Type: application/json"
-H "Authorization: Bearer 1234512345"
-d @$json

```

... it should be:

```auto
-X POST -H "Revolut-Api-Version: 2023-09-01" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer 1234512345" -d @$json

```

To make the cURL options calc a bit simpler I would probably specify it as:

```auto
 "-X POST
-H \"Revolut-Api-Version: 2023-09-01\" 
-H \"Accept: application/json\"
-H \"Content-Type: application/json\"
-H \"Authorization: Bearer " & $secretKey & "
-d @$json"

```

Note that although I have each option on a new line in the Specify Calculation dialog, these new lines actually evaluate as single spaces, so results in the desired single line... Here it is in Data Viewer:

 ![Screenshot 2024-04-29 at 07.58.50](https://canada1.discourse-cdn.com/flex030/uploads/fmsoup/original/2X/2/2dd31800e2979a6f7456d531b41b46e9401dcd74.png)

---

<div class="post-metadata">

**Author:** ![Malcolm](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/malcolm/32/196_2.png) [@Malcolm](https://the.fmsoup.org/u/Malcolm)\
**Post date:** [April 29, 2024, 7:05am UTC](https://the.fmsoup.org/t/insert-from-url-to-revolut-api-not-working-from-filemaker/4104/5 "2024-04-29T07:05:02Z")

</div>

thanks for clarifying my error @skywillmott.

I know that in the places I'm POSTing I haven't used the List function but I didn't realise it would interfere. I assumed that white space was not significant.

---

<div class="post-metadata">

**Author:** ![Anatole](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/anatole/32/368_2.png) [@Anatole](https://the.fmsoup.org/u/Anatole)\
**Post date:** [April 30, 2024, 10:24pm UTC](https://the.fmsoup.org/t/insert-from-url-to-revolut-api-not-working-from-filemaker/4104/6 "2024-04-30T22:24:34Z")

</div>

Thanks for that. I have put the URL into the Insert from URL script step, but put it here too for comepleteness. It makes no difference if I take it out.

Get (Last Error) shows [1631] Connection Failed

Get(LastExternalErrorDetail) shows nothing

```auto
--location "https://merchant.revolut.com/api/orders"
--header “Revolut-Api-Version: 2023-09-01”
--header “Accept: application/json”
--header “Content-Type: application/json”
--header “Authorization: Bearer <<APIkey>>”
--data @$json
--trace $$trace
--show-error

```

$json

```auto
JSONSetElement ( "{}"; ["amount"; 60000 ; 2]; ["currency"; "EUR"; 1])

```

---

<div class="post-metadata">

**Author:** ![xochi](https://avatars.discourse-cdn.com/v4/letter/x/0ea827/32.png) [@xochi](https://the.fmsoup.org/u/xochi)\
**Post date:** [May 1, 2024, 5:39pm UTC](https://the.fmsoup.org/t/insert-from-url-to-revolut-api-not-working-from-filemaker/4104/7 "2024-05-01T17:39:34Z")

</div>

I just noticed something - you are using smart quotes, e.g.  
`--header “Revolut-Api-Version: 2023-09-01”`  
which is not the same as regular quotes:  
`--header "Revolut-Api-Version: 2023-09-01"`

When i try this using proper quoting, like this:

```auto
"--header \"Revolut-Api-Version: 2023-09-01\" 
 --header \"Accept: application/json\" 
 --header \"Content-Type: application/json\" 
 --header \"Authorization: Bearer 1234567890\" 
 --data @$json
 --trace $$trace
 --show-error
"

```

I get this message:

`{"code":"unauthenticated","message":"Authentication failed","timestamp":1714584976753}`

And error is  
`1627 - FileMaker error: 1627`

And since I don't have an API key (I'm just using 1234567...) the failure seems expected and normal.

---

<div class="post-metadata">

**Author:** ![Anatole](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/anatole/32/368_2.png) [@Anatole](https://the.fmsoup.org/u/Anatole)\
**Post date:** [May 2, 2024, 11:43am UTC](https://the.fmsoup.org/t/insert-from-url-to-revolut-api-not-working-from-filemaker/4104/8 "2024-05-02T11:43:38Z")

</div>

Thanks Xoxhi - the quotes seem to make no difference (I have tried both). As far as I can make out, the handshaking is all working fine - al though from FileMaker I get the same result with a bogus API key and a correct one, so maybe there is something in this that is not working.

Thanks again

Currently I am testing with this code loaded into a text field for using as the cURLoptions:

```auto
--header 'Revolut-Api-Version: 2023-09-01' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer @$APIkey' \
--trace $$trace
--data @$json

```

---

<div class="post-metadata">

**Author:** ![Anatole](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/anatole/32/368_2.png) [@Anatole](https://the.fmsoup.org/u/Anatole)\
**Post date:** [May 6, 2024, 9:17am UTC](https://the.fmsoup.org/t/insert-from-url-to-revolut-api-not-working-from-filemaker/4104/9 "2024-05-06T09:17:57Z")

</div>

One question I have Xochi if you would be so kind - how do you get your error response?

I can read the trace, but the only error I get when using a with or without a legitimate APIkey is "Connection Failed", Error 1631.

Thanks very much

---

<div class="post-metadata">

**Author:** ![samfmp](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@samfmp](https://the.fmsoup.org/u/samfmp)\
**Post date:** [May 6, 2024, 2:06pm UTC](https://the.fmsoup.org/t/insert-from-url-to-revolut-api-not-working-from-filemaker/4104/10 "2024-05-06T14:06:15Z")

</div>

Hi, have you tried the following tools to translate the curl?

> **[Translating Auto-generated cURL to FileMaker cURL](https://www.soliantconsulting.com/blog/translating-auto-generated-curl-to-filemaker-curl/)**
>
> Learn how to translate auto-generated cURL to FileMaker cURL from a Claris FileMaker consultant and helpful demo file.

or use this one if you are familiar with JSON.

> **[GitHub - proofgeist/mfm-http: A single script that can handle all HTTP...](https://github.com/proofgeist/mfm-http)**
>
> A single script that can handle all HTTP requests with Filemaker - proofgeist/mfm-http

---

<div class="post-metadata">

**Author:** ![xochi](https://avatars.discourse-cdn.com/v4/letter/x/0ea827/32.png) [@xochi](https://the.fmsoup.org/u/xochi)\
**Post date:** [May 6, 2024, 2:25pm UTC](https://the.fmsoup.org/t/insert-from-url-to-revolut-api-not-working-from-filemaker/4104/11 "2024-05-06T14:25:03Z")

</div>

> [@Anatole](#):
>
> how do you get your error response

Download my sample project [here](https://xochi.com/fm/curl_test/curl_test.fmp12.zip)

---

<div class="post-metadata">

**Author:** ![Anatole](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/anatole/32/368_2.png) [@Anatole](https://the.fmsoup.org/u/Anatole)\
**Post date:** [May 6, 2024, 4:04pm UTC](https://the.fmsoup.org/t/insert-from-url-to-revolut-api-not-working-from-filemaker/4104/12 "2024-05-06T16:04:50Z")

</div>

Thanks so much for your help.

Just worked out the difference between your code and mine - I put an extra '/' at the end of the URL!

I added the APIkey to your version and my corrected code and it still fails authentication. I will take this up with Revolut as I think it should be working now. There is still something peculiar about the actual output of FileMaker that the Revolut server doesn't agree with. It may just be one of the odd characters in the APIkey or something daft like that.

I will let you know how it goes. Thanks so much for your help - it is encouraging that I am so close.

---

<div class="post-metadata">

**Author:** ![Anatole](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/anatole/32/368_2.png) [@Anatole](https://the.fmsoup.org/u/Anatole)\
**Post date:** [May 6, 2024, 4:06pm UTC](https://the.fmsoup.org/t/insert-from-url-to-revolut-api-not-working-from-filemaker/4104/13 "2024-05-06T16:06:16Z")

</div>

Oh - brilliant. Thanks very much.

I will give these a go too.

At the moment, the cURL script in its simplest form is failing on the authentication.

---

<div class="post-metadata">

**Author:** ![Anatole](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/anatole/32/368_2.png) [@Anatole](https://the.fmsoup.org/u/Anatole)\
**Post date:** [May 6, 2024, 7:07pm UTC](https://the.fmsoup.org/t/insert-from-url-to-revolut-api-not-working-from-filemaker/4104/14 "2024-05-06T19:07:22Z")

</div>

Tried the fmParser from Solent. Took working code from Terminal and pasted into fmParser. But it still fails authentication from FileMaker!

---

<div class="post-metadata">

**Author:** ![samfmp](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@samfmp](https://the.fmsoup.org/u/samfmp)\
**Post date:** [May 6, 2024, 8:50pm UTC](https://the.fmsoup.org/t/insert-from-url-to-revolut-api-not-working-from-filemaker/4104/15 "2024-05-06T20:50:23Z")

</div>

Ok, I don't have a business account so it is difficult for me to help.  
I have created a sample file referencing other APIs, could you fill in the API Key in the script step and execute the script once, and see the result, headers, and trace?

[RevolutAPISample.fmp12](https://the.fmsoup.org/uploads/short-url/3C4bVGo5NwH5hhR5dctN1MWSvT5.fmp12) (284 KB)

---

<div class="post-metadata">

**Author:** ![Anatole](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/anatole/32/368_2.png) [@Anatole](https://the.fmsoup.org/u/Anatole)\
**Post date:** [May 7, 2024, 11:25am UTC](https://the.fmsoup.org/t/insert-from-url-to-revolut-api-not-working-from-filemaker/4104/16 "2024-05-07T11:25:53Z")

</div>

Thanks for everyones help here. At last I have it working.

I have at last located the issue(s) with the formatting of my cURL from FileMaker and the Revolut API is now accepting my authentication and responding correctly. It was just a peculiar bit of formatting that was holding the whole thing up.

I have been assembling the Insert from URL script step with variables holding url, cURL options (header) and data (JSON formatted). Adding the APIkey to the cURL options from a variable was not giving a result that was being accepted. By storing the APIkey in a text field and substituting it into the header cURL, it is now being accepted.

---

<div class="post-metadata">

**Author:** ![Anatole](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/anatole/32/368_2.png) [@Anatole](https://the.fmsoup.org/u/Anatole)\
**Post date:** [May 27, 2024, 10:19am UTC](https://the.fmsoup.org/t/insert-from-url-to-revolut-api-not-working-from-filemaker/4104/17 "2024-05-27T10:19:00Z")

</div>

Ah - one issue still that won't play ball. As before the working code in postman & terminal, just doesn't translate to work in FileMaker:

To cancel a payment, I have to submit the following:

```auto
curl --location --request POST 'https://merchant.revolut.com/api/1.0/orders/663fcc98-348e-a7af-89be-9fff6ade2c86/cancel?=' \
--header 'Authorization: ••••••'

```

In FileMaker I just receive a length error in the result\*\*:

```auto
$UUID = GetAsURLEncoded ("<<UUID from record>>")
$APIkey = GetAsURLEncoded ("<<apikey>>")
$url = "https://merchant.revolut.com/api/1.0/orders/" & $UUID & "/cancel?="
$header = "-X POST --header \"Revolut-Api-Version: 2023-09-01\" --header \"Accept: application/json\" --header \"Content-Type: application/json\" --header \"Authorization: Bearer TempToken\" -D $header"
$curl_options = Substitute ( $header ; "TempToken" ; $APIkey
 )
Insert from URL [Select; With dialog: Off; Target: $results; $url; Verify SSL Certificates; cURL options: $curl_options]

```

P.s. Substituting 'TempToken' for the API key was the only way I could get any of this to work. The only difference here is in the url query script containing the UUID and the lack of payload data. The $header and $curl\_options work for other functions (create and retrieve payments). Postman put the "?=" on the end of the URL, which seems to make no difference. Should I be posting a blank data payload - and if so what?

Note: the payment ID shown here is an example from a record successfully cancelled. I am not trying to cancel records again that are already cancelled.

\*\* the error reporting seems to tell me nothing. Trace shows nothing that I can decipher either.

---

<div class="post-metadata">

**Author:** ![jwilling](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/jwilling/32/256_2.png) [@jwilling](https://the.fmsoup.org/u/jwilling)\
**Post date:** [May 27, 2024, 7:43pm UTC](https://the.fmsoup.org/t/insert-from-url-to-revolut-api-not-working-from-filemaker/4104/18 "2024-05-27T19:43:45Z")

</div>

It might be complaining that you're doing a POST but not passing any content via the `-d` option.

But to more quickly get to the bottom of it, I recommend installing `ngrok` on your computer, and then you can use that to create a temporary http server and inspect web requests. `ngrok http 5000`

Once running you can open the web interface in your browser at `http://localhost:4040` and inspect web requests made to the temporary url that ngrok provisioned for you. You can make the "same" request from postman and filemaker, and look for differences.

 ![Screenshot 2024-05-27 at 12.41.17 PM](https://canada1.discourse-cdn.com/flex030/uploads/fmsoup/original/2X/f/fe534d0b267c38e67a21a902ba191bef0f0072ed.png)

Another tool I like for this kind of stuff, which you can easily run in docker is: [https://httpbin.org/](https://httpbin.org/)

---

<div class="post-metadata">

**Author:** ![Anatole](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/anatole/32/368_2.png) [@Anatole](https://the.fmsoup.org/u/Anatole)\
**Post date:** [May 27, 2024, 10:31pm UTC](https://the.fmsoup.org/t/insert-from-url-to-revolut-api-not-working-from-filemaker/4104/19 "2024-05-27T22:31:51Z")

</div>

Bingo!

Thanks so much. I knew it was something stupid. And sure enough it was just objecting to not being sent any data.

I added ---data @$json to the header, where $json = JSONSetElement ( "{}"; [""; 0 ; 2])

... and it loved it.

So thanks so much for the nudge in the right direction. I had already tried it, but not in quite the right way.
