Jump to content

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


This topic is 623 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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!

 

 

Posted
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.

 

Posted

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!

Posted
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.

 

Posted
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.

Posted
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...

This topic is 623 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.