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.

Emma API Integration / Unable to parse JSON request via Insert from URL

Featured Replies

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.

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

  • Author
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.

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

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

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

 

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.