June 28, 20187 yr 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.
June 28, 20187 yr 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 June 28, 20187 yr by ggt667
June 29, 20187 yr 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.
July 3, 20187 yr If it's not already in MacOS High Sierra: brew install netcat nc -l 8080 ( Any port above 1024 should work without sudo ) Edited July 3, 20187 yr by ggt667
July 3, 20187 yr 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
April 18, 20196 yr 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