# Getting INSERT FROM URL To parse JSON Data?

**URL:** https://the.fmsoup.org/t/getting-insert-from-url-to-parse-json-data/3738
**Category:** Questions
**Tags:** community
**Created:** [October 9, 2023, 11:10am UTC](https://the.fmsoup.org/t/getting-insert-from-url-to-parse-json-data/3738 "2023-10-09T11:10:53Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![OliverBarrett](https://avatars.discourse-cdn.com/v4/letter/o/f19dbf/32.png) [@OliverBarrett](https://the.fmsoup.org/u/OliverBarrett)
#### Post date: [October 9, 2023, 11:10am UTC](https://the.fmsoup.org/t/getting-insert-from-url-to-parse-json-data/3738/1 "2023-10-09T11:10:53Z")

</div>

As I find is often the case, getting a complex request to work is often very simple in POSTMAN and even a programming language found in .NET, but getting it to work in FileMaker can be quite time consuming.

Below is some JSON I want to pass to a POST Request using " **--data $jsonData**" The JSON is below, but regardless of what I try (hour after hour ... in FileMaker), I keep getting parse errors.

**{"detail":"Failed to parse request body as JSON: unexpected EOF","status":400}**

FileMaker **set variable** statement value below:

![json parse](https://canada1.discourse-cdn.com/flex030/uploads/fmsoup/original/2X/1/1a3addf981f4cf79729edd257f59299f0ae86aa2.png)

(I had to upload an image above so I didn't need to further refine my JSON so FMSOUP would show all the data.)

Can anyone see what I need to do to make FileMaker happy? I tried copying the working CURL from POSTMAN also and quoting that, but FileMaker won't work with that either.

Thanks in advance,

---

<div class="post-metadata">

### Author: ![FabriceN](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/fabricen/32/2506_2.png) [@FabriceN](https://the.fmsoup.org/u/FabriceN)
#### Post date: [October 9, 2023, 2:05pm UTC](https://the.fmsoup.org/t/getting-insert-from-url-to-parse-json-data/3738/2 "2023-10-09T14:05:34Z")

</div>

Is there a reason not to use JSONSetElements? is the order of the keys important?  
If not, try:

```auto
JSONSetElement ( ""
; ["version" ; "<version_info_here>" ; jsonstring]
; ["input" ; jsonsetelement ( "" ; "text" ; "TEST" ; jsonstring ) ; jsonobject]
; ["webhook" ; "<webhook_url_here>" ; jsonstring]
; ["webhook_events_filter[0]" ; "start" ; jsonstring ]
; ["webhook_events_filter[1]" ; "output" ; jsonstring ]
; ["webhook_events_filter[2]" ; "logs" ; jsonstring ]
; ["webhook_events_filter[3]" ; "completed" ; jsonstring ]
)

```

---

<div class="post-metadata">

### Author: ![OliverBarrett](https://avatars.discourse-cdn.com/v4/letter/o/f19dbf/32.png) [@OliverBarrett](https://the.fmsoup.org/u/OliverBarrett)
#### Post date: [October 9, 2023, 2:32pm UTC](https://the.fmsoup.org/t/getting-insert-from-url-to-parse-json-data/3738/3 "2023-10-09T14:32:01Z")

</div>

> [@FabriceN](#):
>
> ```auto
> JSONSetElement ( ""
> ; ["version" ; "<version_info_here>" ; jsonstring]
> ; ["input" ; jsonsetelement ( "" ; "text" ; "TEST" ; jsonstring ) ; jsonobject]
> ; ["webhook" ; "<webhook_url_here>" ; jsonstring]
> ; ["webhook_events_filter[0]" ; "start" ; jsonstring ]
> ; ["webhook_events_filter[1]" ; "output" ; jsonstring ]
> ; ["webhook_events_filter[2]" ; "logs" ; jsonstring ]
> ; ["webhook_events_filter[3]" ; "completed" ; jsonstring ]
> )
> 
> ```

Brilliant, thank you! It works!!! 🙂

---

<div class="post-metadata">

### Author: ![OliverBarrett](https://avatars.discourse-cdn.com/v4/letter/o/f19dbf/32.png) [@OliverBarrett](https://the.fmsoup.org/u/OliverBarrett)
#### Post date: [October 9, 2023, 6:20pm UTC](https://the.fmsoup.org/t/getting-insert-from-url-to-parse-json-data/3738/4 "2023-10-09T18:20:58Z")

</div>

Hey @FabriceN,

I noticed if I add a second word to the "text" entry using your JSONSetElement example, I again get the could not parse error: **{"detail":"Failed to parse request body as JSON: unexpected EOF","status":400}**

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

If I just used a single word like "write", it works.

I tried different JSONSetElement options like "{}" and JSONString, etc., but none worked. Do you see what's missing now?

(Adding words works as before in POSTMAN CURL and Python.)

Thanks again.

---

<div class="post-metadata">

### Author: ![FabriceN](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/fabricen/32/2506_2.png) [@FabriceN](https://the.fmsoup.org/u/FabriceN)
#### Post date: [October 9, 2023, 10:07pm UTC](https://the.fmsoup.org/t/getting-insert-from-url-to-parse-json-data/3738/5 "2023-10-09T22:07:56Z")

</div>

Sorry, no idea.

---

<div class="post-metadata">

### Author: ![steve\_ssh](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/steve_ssh/32/160_2.png) [@steve\_ssh](https://the.fmsoup.org/u/steve_ssh)
#### Post date: [October 9, 2023, 11:06pm UTC](https://the.fmsoup.org/t/getting-insert-from-url-to-parse-json-data/3738/6 "2023-10-09T23:06:43Z")

</div>

Hi @OliverBarrett ,

A couple of thoughts:

1. If you happened to be including a Content-Length header in the specified "cURL options" of the Insert From URL script step, then modifying the content size without updating the value specified by such a header could play out as you are seeing, especially if the actual content size exceeds what the header is indicating.

2. Please feel free to post a screenshot of the FileMaker script steps and the supporting calculations. Having more eyes on it could help.

Hope this might help.

---

<div class="post-metadata">

### Author: ![apjcs](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/apjcs/32/2502_2.png) [@apjcs](https://the.fmsoup.org/u/apjcs)
#### Post date: [October 10, 2023, 9:51am UTC](https://the.fmsoup.org/t/getting-insert-from-url-to-parse-json-data/3738/7 "2023-10-10T09:51:41Z")

</div>

I am curious, is there a reason not to use this calculation?

```auto
JSONSetElement ( ""
; ["version" ; "<version_info_here>" ; jsonstring]
; ["input.text" ; "TEST" ; jsonstring]
; ["webhook" ; "<webhook_url_here>" ; jsonstring]
; ["webhook_events_filter[0]" ; "start" ; jsonstring ]
; ["webhook_events_filter[1]" ; "output" ; jsonstring ]
; ["webhook_events_filter[2]" ; "logs" ; jsonstring ]
; ["webhook_events_filter[3]" ; "completed" ; jsonstring ]
)

```

which seems simpler

---

<div class="post-metadata">

### Author: ![OliverBarrett](https://avatars.discourse-cdn.com/v4/letter/o/f19dbf/32.png) [@OliverBarrett](https://the.fmsoup.org/u/OliverBarrett)
#### Post date: [October 10, 2023, 10:06am UTC](https://the.fmsoup.org/t/getting-insert-from-url-to-parse-json-data/3738/8 "2023-10-10T10:06:24Z")

</div>

Both produce seemingly valid JSON, but neither works in FileMaker.

**{"detail":"Failed to parse request body as JSON: unexpected EOF","status":400}**

The IFURL has:

"--data " & $jsonData

The header top lines of CURL Options are:

"--X POST " &  
"--header "Authorization: \<auth\_here\>"&  
"--header "Content-Type: application/json""

In Python where I can easily add raw JSON, this works fine.

In POSTMAN, this works fine.

???

Thanks

---

<div class="post-metadata">

### Author: ![FabriceN](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/fabricen/32/2506_2.png) [@FabriceN](https://the.fmsoup.org/u/FabriceN)
#### Post date: [October 10, 2023, 10:19am UTC](https://the.fmsoup.org/t/getting-insert-from-url-to-parse-json-data/3738/9 "2023-10-10T10:19:15Z")

</div>

Absolutely no reason indeed. But it makes me look more knowledgeable 😉  
Of course you're right.

---

<div class="post-metadata">

### Author: ![apjcs](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/apjcs/32/2502_2.png) [@apjcs](https://the.fmsoup.org/u/apjcs)
#### Post date: [October 10, 2023, 10:27am UTC](https://the.fmsoup.org/t/getting-insert-from-url-to-parse-json-data/3738/10 "2023-10-10T10:27:13Z")

</div>

That's a relief. I had a moment of self doubt where I thought I might have missed something important/significant...

---

<div class="post-metadata">

### Author: ![OliverBarrett](https://avatars.discourse-cdn.com/v4/letter/o/f19dbf/32.png) [@OliverBarrett](https://the.fmsoup.org/u/OliverBarrett)
#### Post date: [October 10, 2023, 10:32am UTC](https://the.fmsoup.org/t/getting-insert-from-url-to-parse-json-data/3738/11 "2023-10-10T10:32:58Z")

</div>

Since this could be a bug of some kind, I posted a message on the FileMaker forum about this.

For the moment, we'll not try to do this JSON processing in FileMaker and use an external approach.

I will post back with any updates.

Thanks to all for the great suggestions.

---

<div class="post-metadata">

### Author: ![apjcs](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/apjcs/32/2502_2.png) [@apjcs](https://the.fmsoup.org/u/apjcs)
#### Post date: [October 10, 2023, 10:47am UTC](https://the.fmsoup.org/t/getting-insert-from-url-to-parse-json-data/3738/12 "2023-10-10T10:47:32Z")

</div>

I have found that this works reliably as FileMaker take care of any quoting and escaping...

```auto
"-X POST 
-H \"Content-type: application/json\" 
-H \"accept: application/json\" 
-H \"Authorization: <auth_here>\" 
-d @$jsonData"

```

---

<div class="post-metadata">

### Author: ![OliverBarrett](https://avatars.discourse-cdn.com/v4/letter/o/f19dbf/32.png) [@OliverBarrett](https://the.fmsoup.org/u/OliverBarrett)
#### Post date: [October 10, 2023, 5:12pm UTC](https://the.fmsoup.org/t/getting-insert-from-url-to-parse-json-data/3738/14 "2023-10-10T17:12:17Z")

</div>

The problem turned out to be that I didn't use the "@" in the '-d' portion of CURL options. I've never needed the "@" but I am happy to say that I learned something new and useful going forward.

Thanks again to all! 🙂
