Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted

I am working on an API integration from FileMaker 17 to Emma. Generally when I work on a new API, I get the curl working on the command line and then translate that into FM. But I've hit a roadblock with one particular API call while my other API calls to Emma are successful. (In the example below, I substituted out sensitive data with all caps.)

From the command line, the code is:

curl -u USER:PASS -H "Accept:application/json" -H "Content-type: application/json" -X POST -d '{"fields": {"name_first": "TESTFIRST","name_last": "TESTLAST","eligible": "false","expiration": "@D:2019-06-30"},"group_ids": ["GROUPIDNUMBER"],"email": "[email protected]","opt_in_confirmation": "false"}' "https://api.e2ma.net/ACCOUNTNUMBER/members/signup"

This command is successful.  The server responds with the individuals' emma id and group confirmation. 

This fails using Insert from URL within FM though. While eventually I'll use FileMaker fields for an individual record's names, email, and expiration dates, I did not use fields in my testing in order to duplicate the command line exactly. In Insert from URL:

The URL is "https://api.e2ma.net/ACCOUNTNUMBER/members/signup"

The curl option is "-u USER:PASS -H \"Accept:application/json\" -H \"Content-type: application/json\" -X POST -d '{\"fields\": {\"name_first\": \"TESTFIRST\",\"name_last\": \"TESTLAST\",\"eligible\": \"false\",\"expiration\": \"@D:2101-06-30\"},\"group_ids\": [\"GROUPIDNUMBER\"],\"email\": \"[email protected]\",\"opt_in_confirmation\": \"false\"}'"

 

Can anyone identify the problem or suggest a workaround? My experience with API integration with FM is limited, but anything I could get working via the command line, I've been able to get working within FM until this.

Posted (edited)

To track down this issue I would change the URL to 0.0.0.0 80 and launch netcat; as such: nc -l 8080 and change my queries accordingly; using the URL: localhost:8080, then I would compare what the queries look like on the server side.

Edited by ggt667
Posted
20 hours ago, ggt667 said:

To track down this issue I would change the URL to 0.0.0.0 80 and launch netcat; as such: nc -l 8080 and change my queries accordingly; using the URL: localhost:8080, then I would compare what the queries look like on the server side.

I was looking for a tool like this to understand how my FM changes impacted the call being made. Thanks for this! I've never used it and having a bit of a learning curve, but I'll keep plugging away at it. If I can get the tool working, it sounds like it will be invaluable as I expand my solutions to involve more and more API integrations.

Posted (edited)

If it's not already in MacOS High Sierra: brew install netcat

nc -l 8080

( Any port above 1024 should work without sudo )

Edited by ggt667
Posted

I would consider defining your json as a variable and referencing that variable in your curl options. That takes care of all the quoting for whitespaces and such in your json. Note how you reference the variable you set in the curl options needs to be inside the quote marks, like:

"--data @$myVariable"

I have also written a php page that returns headers and payloads you send to it. You can get it here: https://github.com/SoliantMike/PHP-HTTPDebug

Lastly, you can also use the "--dump-header" curl option to set returned headers to a variable that you can inspect in FM to troubleshoot as well.

Hth,
Mike

  • 9 months later...
  • Newbies
Posted

I've been searching for days on this problem

This is my solution:

Var A

"
-H \"Authorization: Bearer d38ed55f65690b37b6f2db4329009e7221f80617e77029ce465b079eb390a893\"
" & "
-H \"Accept-version: 1.0.0\"
" & "
-H \"Content-Type: application/json\"
" & "
-X POST \ "

 

Var B (type your Json in a field and use a calculation to end up with a variable)

JsonFormatElements 

 

Var C 

"--data @$varB"

 

Insert from URL

cURL options: varA & varC

 

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