# Cannot get INSERT FROM URL headers to work

**URL:** <https://the.fmsoup.org/t/cannot-get-insert-from-url-headers-to-work/1560>\
**Category:** Questions\
**Tags:** community\
**Created:** [December 30, 2020, 12:54pm UTC](https://the.fmsoup.org/t/cannot-get-insert-from-url-headers-to-work/1560 "2020-12-30T12:54:08Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon45965781](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@anon45965781](https://the.fmsoup.org/u/anon45965781)\
**Post date:** [December 30, 2020, 12:54pm UTC](https://the.fmsoup.org/t/cannot-get-insert-from-url-headers-to-work/1560/1 "2020-12-30T12:54:08Z")

</div>

As with so many postings, POSTMAN works fine, but I cannot figure out how to get FMP to accept the URL parameters and I would appreciate some guidance.

As you can see on this site:

> **[Rosette API | Features & Functions](https://developer.rosette.com/features-and-functions?shell#entity-extraction-and-linking-language-support)**

The expected CURL parameters are:

curl -s -X POST   
-H "X-RosetteAPI-Key: your\_api\_key"   
-H "Content-Type: application/json"   
-H "Accept: application/json"   
-H "Cache-Control: no-cache"   
-d '{"content": "Por favor Señorita, says the man." }'   
"[https://api.rosette.com/rest/v1/language](https://api.rosette.com/rest/v1/language)"

**In FileMaker** , I tried putting the test text right in the "-d" above, but that didn't work so I created a field for it.

My FileMaker URL Parameters are:

"--X POST " &  
"--header "X-RosetteAPI-Key: 123456789"" &  
"--header "Content-Type: application/json"" &  
"--header "Accept: application/json"" &  
"--header "Cache-Control: no-cache"" &  
"--data " " & GetAsURLEncoded(Rosette Language::theJson)

**But, I get this error back:**

{"code":"badRequestFormat","message":"Unexpected character ('%' (code 37)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false')\n at [Source: (org.apache.cxf.transport.http.AbstractHTTPDestination$1); line: 1, column: 3]","stack":null}

My form, for what it's worth, looks like this:

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/fmsoup/original/2X/d/d57eafeb0ff67a2c1bd02af9ff6d9f60303c6bee.png)

Can anyone see why FileMaker is failing? I've worked at this for hours now....

Thanks!

---

<div class="post-metadata">

**Author:** ![villegld](https://avatars.discourse-cdn.com/v4/letter/v/f1d935/32.png) [@villegld](https://the.fmsoup.org/u/villegld)\
**Post date:** [December 30, 2020, 1:06pm UTC](https://the.fmsoup.org/t/cannot-get-insert-from-url-headers-to-work/1560/2 "2020-12-30T13:06:50Z")

</div>

> Blockquote  
> "--X POST " &  
> "--header "X-RosetteAPI-Key: 123456789"" &  
> "--header "Content-Type: application/json"" &  
> "--header "Accept: application/json"" &  
> "--header "Cache-Control: no-cache"" &  
> "--data " " & GetAsURLEncoded(Rosette Language::theJson)

1. You need to add whitespace end of each line (or new line ¶) (""--header "X-RosetteAPI-Key: 123456789" " &)
2. Add backslash \ before double quotes inside quoted text ("--header "Cache-Control: no-cache" " &...)
3. Store data into variable before insert from url and read data from that variable ("--data @$post\_data")

You can read more from fm help: [Supported cURL options](https://help.claris.com/en/pro-help/content/curl-options.html?Highlight=insert%20from%20url)

EDIT: Ok you might had already backslashes because this editor strips those from the text

---

<div class="post-metadata">

**Author:** ![WimDecorte](https://avatars.discourse-cdn.com/v4/letter/w/b19c9b/32.png) [@WimDecorte](https://the.fmsoup.org/u/WimDecorte)\
**Post date:** [December 30, 2020, 1:34pm UTC](https://the.fmsoup.org/t/cannot-get-insert-from-url-headers-to-work/1560/3 "2020-12-30T13:34:15Z")

</div>

consider using a set of custom functions to help build your cURL syntax. It takes care of all the escaping etc

> **[How to Send SSL Certificate with “Insert from URL” Request | FileMaker 19](https://www.soliantconsulting.com/blog/curl-options-filemaker-19/)**
>
> Learn about new cURL options in FileMaker 19 and how to send an SSL certificate along with your “Insert from URL” requests here.

Also, you don't need to URL encode your json. Just stick the json in a variable and feed it in that way. If you don't want to use CFs to build the syntax then make that last line with the data:

"-d @$json"

Note that $json is hard-wired in the string, no concatenation. It's an odd syntax for FM but that's the way it is meant to work.

---

<div class="post-metadata">

**Author:** ![anon45965781](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@anon45965781](https://the.fmsoup.org/u/anon45965781)\
**Post date:** [December 30, 2020, 2:04pm UTC](https://the.fmsoup.org/t/cannot-get-insert-from-url-headers-to-work/1560/4 "2020-12-30T14:04:39Z")

</div>

Brilliant! Thanks Wim....It works!!! 🙂

---

<div class="post-metadata">

**Author:** ![jeremyb](https://avatars.discourse-cdn.com/v4/letter/j/ad7895/32.png) [@jeremyb](https://the.fmsoup.org/u/jeremyb)\
**Post date:** [December 30, 2020, 7:38pm UTC](https://the.fmsoup.org/t/cannot-get-insert-from-url-headers-to-work/1560/5 "2020-12-30T19:38:31Z")

</div>

Also consider this:

> **[HTTP Request: I don't know how but it works - Geist Interactive](https://www.geistinteractive.com/2019/11/08/http-request-i-dont-know-how-but-it-works/)**
>
> The HTTP Request script works to get a response from an API in all cases. All it needs is some parameters. We don't need to know how it works; it just does!

This script (like a function) takes parameters and does the entire work for you including the Insert from URL and then gives you back the response. . .  
It handles every type of Insert from URL.

---

<div class="post-metadata">

**Author:** ![anon45965781](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@anon45965781](https://the.fmsoup.org/u/anon45965781)\
**Post date:** [December 30, 2020, 7:56pm UTC](https://the.fmsoup.org/t/cannot-get-insert-from-url-headers-to-work/1560/6 "2020-12-30T19:56:11Z")

</div>

Thank you! 🤓

It's a wonder a utility like that wasn't in FileMaker to begin with. Setting CURL options is a dark art in FileMaker (still in 19) with ZERO help from the product itself -- you're literally on your own.

---

<div class="post-metadata">

**Author:** ![Cecile](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/cecile/32/98_2.png) [@Cecile](https://the.fmsoup.org/u/Cecile)\
**Post date:** [December 31, 2020, 4:47pm UTC](https://the.fmsoup.org/t/cannot-get-insert-from-url-headers-to-work/1560/7 "2020-12-31T16:47:27Z")

</div>

But you can call up our friends, and you know, whenever one can, they’ll come running to help you again... Servers scripts schema and all, all you have to do is post, the soup is here with answers for you...

---

<div class="post-metadata">

**Author:** ![FileKraft](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/filekraft/32/1183_2.png) [@FileKraft](https://the.fmsoup.org/u/FileKraft)\
**Post date:** [December 31, 2020, 5:00pm UTC](https://the.fmsoup.org/t/cannot-get-insert-from-url-headers-to-work/1560/8 "2020-12-31T17:00:52Z")

</div>

the mind buckling challenge is something working in Postman within minutes but felt eons if ever within FM ..

---

<div class="post-metadata">

**Author:** ![anon45965781](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@anon45965781](https://the.fmsoup.org/u/anon45965781)\
**Post date:** [December 31, 2020, 5:12pm UTC](https://the.fmsoup.org/t/cannot-get-insert-from-url-headers-to-work/1560/9 "2020-12-31T17:12:44Z")

</div>

Yep. True dat! 🤓

---

<div class="post-metadata">

**Author:** ![jormond](https://avatars.discourse-cdn.com/v4/letter/j/35a633/32.png) [@jormond](https://the.fmsoup.org/u/jormond)\
**Post date:** [December 31, 2020, 5:44pm UTC](https://the.fmsoup.org/t/cannot-get-insert-from-url-headers-to-work/1560/10 "2020-12-31T17:44:09Z")

</div>

Most often, I will take the curl code from Postman or Insomnia, and put it in a field, and throw a quote on it. All the escaping is done. And I can just swap out what I need.

So either I can add the needed &, ", or whatever... or I'll just wrap the pieces I need in \< \> and use substitute. I find the latter much easier most of the time.

---

<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:** [January 1, 2021, 12:08am UTC](https://the.fmsoup.org/t/cannot-get-insert-from-url-headers-to-work/1560/11 "2021-01-01T00:08:34Z")

</div>

It's pretty simple once you get used to it, just copy the Postman cURL, remove the url, replace single with double quotes, remove trailing backslashes (`\`), and maybe "template-ify" it if you need to put dynamic data in the curl options. e.g.:

```auto
curl --location --request POST 'https://my-url.com/endpoint' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic MY_SUPER_SECRET_LOGIN_INFO' \
--data-raw '{
    "fmDataSource": [
        {
            "database": "EDS1",
            "username": "username",
            "password": "password"
        },
        {
            "database": "EDS2",
            "username": "username",
            "password": "password"
        }
    ]
}'

```

Becomes $curlTemplate:

```auto
--location
--request POST
--header "Content-Type: application/json"
--header "Authorization: Basic {{auth}}"
--data-raw @$data

```

Then just create $data and $auth in separate variables and substitute in `auth`:  
`Substitute ( $curlTemplate ; "{{auth}}" ; $auth )`

No need to substitute $data because the `@` does so automatically.

---

<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:** [January 1, 2021, 12:10am UTC](https://the.fmsoup.org/t/cannot-get-insert-from-url-headers-to-work/1560/12 "2021-01-01T00:10:54Z")

</div>

I guess that's a long-winded way of saying that, while cURL has some rough edges in FM, I actually think vanilla `Insert From URL` is a pretty fine interface.

---

<div class="post-metadata">

**Author:** ![anon45965781](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@anon45965781](https://the.fmsoup.org/u/anon45965781)\
**Post date:** [January 1, 2021, 1:04pm UTC](https://the.fmsoup.org/t/cannot-get-insert-from-url-headers-to-work/1560/13 "2021-01-01T13:04:38Z")

</div>

That workflow sounds like a great BBEDit "Text Factory" (where you create one or more text modifications to be applied with a single click).

---

<div class="post-metadata">

**Author:** ![anon45965781](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@anon45965781](https://the.fmsoup.org/u/anon45965781)\
**Post date:** [January 1, 2021, 1:06pm UTC](https://the.fmsoup.org/t/cannot-get-insert-from-url-headers-to-work/1560/14 "2021-01-01T13:06:26Z")

</div>

INSERT FROM URL is fine, but offers zero support in the CURL options. It should offer name:value pair pop-up support like POSTMAN, at a minimum, or _something_. Often you don't need any help, but other times it would be, well, helpful.

The zero help, brain dead, FMP CURL options is a sad implementation for a premium paid product, IMHO.

---

<div class="post-metadata">

**Author:** ![jormond](https://avatars.discourse-cdn.com/v4/letter/j/35a633/32.png) [@jormond](https://the.fmsoup.org/u/jormond)\
**Post date:** [January 1, 2021, 3:28pm UTC](https://the.fmsoup.org/t/cannot-get-insert-from-url-headers-to-work/1560/15 "2021-01-01T15:28:52Z")

</div>

Or since you are already in FileMaker, you can do it there also. All about preference.

I have a utilities file that does stuff like that. Throw the text into a filed and that’s it. Don’t even have to click a button.

---

<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:** [January 1, 2021, 6:14pm UTC](https://the.fmsoup.org/t/cannot-get-insert-from-url-headers-to-work/1560/16 "2021-01-01T18:14:30Z")

</div>

Yes!!!

I actually do have a little javascript that does this conversion and even converts the json body into JSONSetElement syntax and breaks the variables into separate steps.

But the repo is private because I wasn’t sure I wanted to get any support requests or anything. Maybe I’ll make it public and slap a big disclaimer “not maintained!” on it.

---

<div class="post-metadata">

**Author:** ![anon45965781](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@anon45965781](https://the.fmsoup.org/u/anon45965781)\
**Post date:** [January 1, 2021, 10:03pm UTC](https://the.fmsoup.org/t/cannot-get-insert-from-url-headers-to-work/1560/17 "2021-01-01T22:03:08Z")

</div>

I had thought about writing a utility like that, but this brain-dead blank page (FMP's URL Options), issue ONLY happens in FileMaker. Other environments have good support for URL parameters.

For example, in Java., it's all object-based.

Just set 'em and it works!

// open URL  
//----------------  
URL url = new URL("\<URL \_TO\_GO\_TO");  
conn = (HttpURLConnection) url.openConnection();  
conn.setDoOutput(true);

// set headers...  
//-----------------------  
conn.setRequest **Method** ("POST");

conn.setRequest **Property** ("Content-Type", "application/json");  
conn.setRequest **Property** ("Accept", "_/_");  
conn.setRequest **Property** ("Cache-Control", "no-cache");  
conn.setRequest **Property** ("some-API-Key", "1234566789");  
.  
.  
.  
(easy)

You would then use an inputstream to read data and an outputstream to write your POST data, etc.

No utility needed. 🙂

---

<div class="post-metadata">

**Author:** ![WimDecorte](https://avatars.discourse-cdn.com/v4/letter/w/b19c9b/32.png) [@WimDecorte](https://the.fmsoup.org/u/WimDecorte)\
**Post date:** [January 2, 2021, 12:05pm UTC](https://the.fmsoup.org/t/cannot-get-insert-from-url-headers-to-work/1560/18 "2021-01-02T12:05:22Z")

</div>

As mentioned before; it's already been solved by the collection of custom function that I linked to early in this thread. Solved many years ago...  
It gives you all the type-ahead you want plus it saves you from having to guess what cURL options are supported.

---

<div class="post-metadata">

**Author:** ![anon45965781](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@anon45965781](https://the.fmsoup.org/u/anon45965781)\
**Post date:** [January 2, 2021, 12:11pm UTC](https://the.fmsoup.org/t/cannot-get-insert-from-url-headers-to-work/1560/19 "2021-01-02T12:11:38Z")

</div>

Thanks, but I really don't want to worry about copying and maintaining a bunch of slow, difficult-to-debug CFs to do what should have been in-product (FMP) long ago. I don't think you will agree with that, but to each their own. To wit, I just created a generic "INSERT FROM URL" alternative in a micro-service. That's a much more powerful approach and is not FMP only.

Pass name:value pairs for headers in simple GET method. Even works from the browser. 🙂

(FileMaker not required.)

Thanks.

---

<div class="post-metadata">

**Author:** ![WimDecorte](https://avatars.discourse-cdn.com/v4/letter/w/b19c9b/32.png) [@WimDecorte](https://the.fmsoup.org/u/WimDecorte)\
**Post date:** [January 2, 2021, 12:52pm UTC](https://the.fmsoup.org/t/cannot-get-insert-from-url-headers-to-work/1560/20 "2021-01-02T12:52:28Z")

</div>

There is nothing inherently slow about CFs. And there is nothing to debug about this particular set of CFs, they're just string builders.  
And 'worry' about scaffolding a solution!? What kind of worry is that? There's scaffolding involved with pretty much every solution in any platform.

If it is not in the solution but provided as a - free and easy - component you'll refuse to use it? Strange. Sounds like "I will be inefficient and that'll teach you"

[Next page](https://the.fmsoup.org/t/cannot-get-insert-from-url-headers-to-work/1560.md?page=2)
