Jump to content

how to pass body raw as curl option for api integration


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

Recommended Posts

Hi,

I find my self hitting the wall, again and again, trying to make a POST call to an API using Insert from URL curl. When I try the code in POSTMAN it works very well, but trying to translate the curl options into Filemaker is where I fail. This is my POSTMAN code:

curl -X POST \
  https://www.correosexpress.com/wpsc/apiRestSeguimientoEnvios/rest/seguimientoEnvios \
  -H 'user: username:passowrd' \
  -H 'Content-Type: application/xml' \
  -H 'Postman-Token: ff84b952-74c8-f06b-976d-f860d9d66de7' \
  -d '<?xml version='\''1.0'\'' encoding='\''UTF-8'\''?><SeguimientoEnviosRequest xmlns:xsi='\''http://www.w3.org/2001/XMLSchema-instance'\'' xsi:noNamespaceSchemaLocation='\''SeguimientoEnviosRequest.xsd'\''><Solicitante>x</Solicitante><Dato>xxxxxxxxxxxxxxxxx</Dato> </SeguimientoEnviosRequest>'

The yellow part is what I should put under "Body" and after in "raw" in POSTMAN and it is just that the one I can not figure out how to put it as a curl option for the Insert from URL... :(. I pass authorisation using username and password, but I get all the time the same error of missing "XML entry template" 

Any idea on how to overcome this error? is the XML entry template the headers that this api needs to have them custom?

Thanks a lot!!!

Link to comment
Share on other sites

Ok... After LOTS of testing I figure out how it should be done, so I am just updating my own post to share the info in case anyother "amateur" developer as myself would encouter similar challenge :)

I just figure out how to pass that "-d" data with the XML code, what I did was:

1) Create variable ( $rawdata ; <?xml version="1.0" encoding="UTF-8"?> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="SeguimientoEnviosRequest.xsd"><Solicitante>1</Solicitante><Dato>xxxxxxxxxxxxxxxx</Dato> </SeguimientoEnviosRequest>)

2) I was using the lumifire example for CURL testing (  https://luminfire.com/2017/06/12/curling-filemaker-16/)  and on the $options variable that is set on their script I just added an extra curl option as: " -d " & "\"" & Substitute ( $rawdata; "\""; "\\\"" ) & "\""

3) FEEL THE JOY!!!!! when I get the XML info back :)

Thanks a lot,

Best regards!

 

Link to comment
Share on other sites

This topic is 2274 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.