Jump to content
Sign in to follow this  
JMW

Curl and Insert From Url not posting

Recommended Posts

I am using FM 17 and am trying to submit some JSON to an 3rd party website to create and insurance claim.  Below is the curl code I am able to run from the command line. 

I tried using Insert From Url to do the same thing and I am unable to get it to work.  I get the following message back when I use Insert From Url: "Message": "The requested resource does not support http method 'GET'."  I need both the information after the question mark on the url and the data after the -d tag.  I think I read somewhere that if a ? and information is included after the url that Filemaker's implementation of Insert From Url assumes a get.  I need to be able to have both and do a post.  Am I missing something?  Any help would be appreciated.  I can use Send Events but would rather use Insert From Url

curl -o apexEdiOutput.txt -X POST https://sandbox.services.apexedi.com/api/V3/claims/submit?vendorSiteId=<vendor site id> --header "Authorization: Basic <base 64 encoded key>" --header "Content-Type: application/json" -d "@<path name and file with json>"

Thanks!

Share this post


Link to post
Share on other sites

In your FM call are you also pointing to the json file on the hard drive somewhere?  That won't work.  FM does not allow sending files like that (for security reasons).  If you have the json in a variable then you can just use -d @$json

Other than that we'd have to see your Insert From URL script step and its cURL options

Share this post


Link to post
Share on other sites

Hmm ... thanks for the input Wim.

I went back and looked at my call to Insert from URL and now have the following code:

Insert from URL [Select; With dialog:On; Trans::_temp field;
"https://sandbox.services.apexedi.com/api/v3/claims/submit?vendorSiteID=<our id>,type=medical;
cURL options:"--location --dump-header $curlHeader --show-error -o $curlOutput -X POST --header \"Authorization: Basic $apexBase64EncodedKey\" --header \"Content-Type: application/json\" --data  & @$claimDataJSON"

I no longer get the message "The request resource does not suport http method Get" but it does redirect it to a production url instead of the test sandbox and says I'm not authorized.  Which is true.  Does anyone know why this is happening?

1627
HTTP/1.1 401 Unauthorized
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 41
Content-Type: text/plain; charset=utf-8
Expires: -1
Server: Microsoft-IIS/8.5
WWW-Authenticate: Basic Scheme='OneTouchWebServiceV3' location='https://production.services.apexedi.com/'
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Mon, 11 Nov 2019 23:37:57 GMT

Keep in mind I can post to the sandbox url using curl and send event.  So either I am or Filemaker is doing something different/wrong on the Insert from Url call.

Thanks for everyone's help.  Hopefully, I can be helpful to someone sometime.

Edited by JMW

Share this post


Link to post
Share on other sites
12 hours ago, JMW said:


cURL options:"--location --dump-header $curlHeader --show-error -o $curlOutput -X POST --header \"Authorization: Basic $apexBase64EncodedKey\" --header \"Content-Type: application/json\" --data  & @$claimDataJSON"

 

 

The section indicated in red is incorrect.  Unlike sending data that is in a variable you cannot do the same for the authorization part.  That has to be a real concatenation:

"...Authorization: Basic " & $apexBase64EncodedKey & "....

 

I think the reference to production in the response is a red herring, it's probably a reference to where they authenticate.

Share this post


Link to post
Share on other sites

Wim,

Thanks for the tip.  It didn't seem to solve the problem in the long run.  It worked for awhile and then stopped, which seems weird.

Edited by JMW

Share this post


Link to post
Share on other sites

Wim,

It turns out that your solution was correct!  The website I was interfacing with had stopped accepting requests from our userid.  

On 11/12/2019 at 5:36 AM, Wim Decorte said:

 

"The section indicated in red is incorrect.  Unlike sending data that is in a variable you cannot do the same for the authorization part.  That has to be a real concatenation:"

Does this imply that a field can't be used for the base 64 encoded key and used in place of the variable?

Edited by JMW

Share this post


Link to post
Share on other sites
40 minutes ago, JMW said:

Wim,

Does this imply that a field can't be used for the base 64 encoded key and used in place of the variable?

 

No, you can still do that.  But unlike the variable used for sending data, in this case you just need to properly concatenate things like in my example.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Similar Content

    • By Franco Pagano
      when inserturl do not have a response it freeze and wait, then i tried using curl : --connect-timeout 1
      but it doesn work.
      please how to interupt the execution on inserturl command at e specific time.
       
      testcurl.fmp12
    • By Osman
      hello all,
      I am using insert from url script step in my server scheduled script with cURL parameters.
      Insert from URL step gives error 1, user cancelled action.
      I have added  --max-time 30 option, but still same error code.
      I changed the url to any regular web page, it works. But it still not works with orginal url (mailgun api url).
      how can I handle this problem?
      regards,
      osman
       
    • By docasar
      Hello,
       
      I am trying to connect to our current database with our shipping company so I can update the status of the delivered orders. To do that, I am currently using insert from URL and then parse the code to extract the info I need. However, I believe there should be a cleaner and safer way to do it using webservice.
      So I downloaded the documentation and looks very straightforward to set and I have been able to set up the POST and send it getting the data as XML using POSTMAN (as very well explained here:  http://www.filemakerprogurus.com/filemaker-api-integration-salvatore-coleangelo/ ) and also in the great post by luminfire https://luminfire.com/2017/06/12/curling-filemaker-16/.
      However, when I try the same parameters on my script in filemaker, I get all the time an error saying that something like  "Entry XML Schema/template it is not loaded correctly". Following the documentation of the API I see that on Postman I need to insert on the Body RAW some kind of code that looks like this: 
      <?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>
      but I don't know which settings I have to do on my script to make the call work.
      Any suggestions as to where to put this info so the can be passed with the CURL? I am a bit desperate now because I see the amazing possibilities that the interaction with the web service may bring but I can find a way to make it work...
      Thanks a lot for your always invaluable support!!
    • By JTSmith
      OK, I'm using FM16 and trying to figure out an API call.  I'm not an expert when it comes to APIs.
      I have a shopify store, and I can use Insert from URL to get the JSON info on each order.  I want to be able to "PUT" and upload parts of the order.  Every order has a "Note" field that I can add notes.  Per the shopify API documentation, to add an order note, you do the following:
      Add Note to order
      PUT /admin/orders/#{id}.json { "order": { "id": 450789469, "note": "Customer contacted us about a custom engraving on this iPod" } }  
      Can someone help me with what I put in the cURL options area?  Any help would be appreciated.  I think I have the URL and Target figured out.  Thank you!!
    • By Kent Searight
      I'm trying to get a token from an authorization server using cURL in Insert From URL. When I make the following request in Terminal
      curl -i -X POST -d 'username=myaccountname&password=mypassword' https://authserver.com/login
      I get the token back in the response header.
      Since FileMaker doesn't support the --include (-i) option I haven't been able to figure out how to get the response header with the token.  Anyone have any ideas on how to accomplish this?

      Thanks in advance!
      -Kent
      UPDATE:
      Okay, I figured out I can get a response header by using the option --dump-header and setting it to a variable. The only problem now is that the token comes from a redirect location and I'm only getting the response header from the original URL. I'll keep working on it but I'll be happy to get whatever advice anyone can offer in the meantime. 
  • Who Viewed the Topic

    7 members have viewed this topic:
    thierryfl  PedroAlex  Randy Bennett  Stefano Parmeggiani  cat traveller  comment  Steve Martino 
×
×
  • Create New...

Important Information

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