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.

Need help: POST XML file via HTTP: "Insert from URL" or via BaseElements functions

Featured Replies

Trying to POST via HTTP to send an XML file to a recipient.

Basically, this is the cURL data that I am trying to use:

--location --request POST "https://medidatabox:8100/md/ela/uploads"
--header "X-CLIENT-ID: 1000004142"
--header "Content-Type: multipart/form-data"
--header "Authorization: Basic SHBERGdnaHFOMm9ScmJtQjpmeFERM5mYTczNERyMW9p"
-F "[email protected];type=application/octet-stream"

I have been trying to use "Insert from URL" and BaseElements "BE_HTTP_SetCustomHeader" and "BE_HTTP_POST", but without success. I am somehow failing to provide the correct info at the correct location (I must assume).

"invoice.xml" is an XML file in a container field. I actually put the XML container file into a variable $xmlFile. 

Client-ID and Authorization are working, as I get a response via GET request. 

Any ideas on how to get this POST to work successfully either via "Insert from URL" or BaseElements functions?

Thank you kindly!

 

 

On 1/24/2022 at 6:03 AM, jschudel said:

I actually put the XML container file into a variable $xmlFile. 

Have you tried:

-F elauploadstream=@$xmlFile

This refers to the Insert from URL script step; I have no experience with the corresponding Base Elements commands.

 

  • Author

When I run curl in the command line like below, I am successful:

--header "X-CLIENT-ID: 1000004142"
--header "Content-Type: multipart/form-data"
--header "Authorization: Basic SHBERGdnaHFOMm9ScmJtQjpmeFERM5mYTczNERyMW9p"
-F "[email protected];type=application/octet-stream"
--insecure

Where invoice.xml is the local XML file. This works great. Note the "--insecure" at the end, this is required, otherwise I get a certificate error. I am connecting to a local machine.

However, I do NOT succeed in FileMaker Pro (19).

If I try to use the built-in script step "Insert from URL", I get "Connection failed". Note that I have not found a way to send the curl attribute "--insecure" trough "Insert from URL", it seems to not be supported.

Insert from URL

URL:

httpspost://172.16.10.114:8100/md/ela/uploads

cURL:

--header "X-CLIENT-ID: 1000004142" 
--header "Content-Type: multipart/form-data" 
--header "Authorization: Basic SHBERGdnaHFOMm9ScmJtQjpmeFERM5mYTczNERyMW9p" 
-F "elauploadstream=@$xmlFile;type=application/octet-stream"

If I try using the BaseElements plugin, I am also NOT successful.

Using these BaseElements functions below...

BE_Curl_Set_Option ( "CURLOPT_SSL_VERIFYPEER" ; 0 )
BE_HTTP_Set_Custom_Header ( "X-CLIENT-ID" ; "1000004142" )
BE_HTTP_Set_Custom_Header ( "Content-Type" ; "multipart/form-data" )
BE_HTTP_Set_Custom_Header ( "Authorization" ; "Basic SHBERGdnaHFOMm9ScmJtQjpmeFERM5mYTczNERyMW9p" )
BE_HTTP_POST ( "https://172.16.10.114:8100/md/ela/uploads" ; "elauploadstream=@$xmlFile&type=application/octet-stream" )

... I get Error 500 (boundaries not defined). (Note that in FileMaker, I have to save the XML file invoice.xml in a variable, in my case $xmlFile.)

Any ideas or help would be greatly appreciated! Thank you!

On 1/31/2022 at 1:50 AM, jschudel said:

Note the "--insecure" at the end, this is required,

You didn't mention this in your original post. According to FMP help, unsupported cURL options are ignored - so if you need this you will have to use a plugin or OS scripting.

P.S.
This is very difficult to read.

 

  • Author
39 minutes ago, comment said:

You didn't mention this in your original post. According to FMP help, unsupported cURL options are ignored - so if you need this you will have to use a plugin or OS scripting.

P.S.
This is very difficult to read.

 

Sorry about the dark background. I use dark reader in my browsers, so I didn't check how it looks in the "light" version. 

The --insecure attribute is something I only figured out after my original post.

I did try with BaseElements with 

BE_Curl_Set_Option ( "CURLOPT_SSL_VERIFYPEER" ; 0 )

which is supposedly the same as "--insecure", but with no success.

 

Obvisouly, HTTP POST vis curl is either super easy in FM (and I am the only one not smart enough to do it) or not used often.

2 minutes ago, jschudel said:

HTTP POST vis curl is either super easy in FM (and I am the only one not smart enough to do it) or not used often.

I believe it depends on the API. Personally, I have used the Insert from URL script to POST only a handful of times - and I did not encounter any special problems. But those APIs had relatively simple requirements compared to yours.

 

  • 1 year later...
  • Newbies

ok

Edited by stairway

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.