Richard Lund
Richard Lund

Reputation: 3

Filemaker eBay Insert from URL API Request, Can XML be formatted in a FM calc?

I am attempting to create an API request using the FileMaker Insert from URL script step. I am able to generate a successful API request with eBay's API explorer. I was able to generate the XML without losing the quotations within FileMaker's Data Viewer. (using escape backslash to correct the XML quotations.) When pasted from the calculation result into eBay's API Explorer it created a successful request. However it fails within the cURL script step calculation for some reason....

How I can format it in a FM calculation so that the eBay API will accept it? (I am glad to hear other process suggestions, perhaps this isn't the best way to do about this.)

API Response from the script:

<?xml version="1.0" encoding="UTF-8" ?><eBay><EBayTime>2023-03-01 22:45:25</EBayTime><Errors><Error><Code>2</Code><ErrorClass>RequestError</ErrorClass><SeverityCode>1</SeverityCode><Severity>SeriousError</Severity><Line>0</Line><Column>0</Column><ShortMessage><![CDATA[ Unsupported verb. ]]></ShortMessage></Error></Errors></eBay>

Here is the header: (less the token)

X-EBAY-API-SITEID:0

X-EBAY-API-COMPATIBILITY-LEVEL:967

X-EBAY-API-CALL-NAME:GetItem

X-EBAY-API-IAF-TOKEN:v^1 (XXXX-OAuth Token XXXX).

Here is the XML:

<?xml version="1.0" encoding="utf-8"?>

<GetItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">

<ErrorLanguage>en_US</ErrorLanguage>

<WarningLevel>High</WarningLevel>

<!--Enter an ItemID-->

<ItemID>155432020294</ItemID>

</GetItemRequest>

Upvotes: 0

Views: 143

Answers (1)

Schwarz Software
Schwarz Software

Reputation: 1552

Try putting your XML into a variable (e.g. $xml) and then use this in your Insert from URL cURL options calc, which based on your header could be specified as:

"-X POST
--header \"X-EBAY-API-SITEID: 0\"
--header \"X-EBAY-API-COMPATIBILITY-LEVEL: 967\"
--header \"X-EBAY-API-CALL-NAME: GetItem\"
--header \"X-EBAY-API-IAF-TOKEN: v^1 (XXXX-OAuth Token XXXX)\"
--data @$xml
"

If that doesn't work and you are more comfortable with cURL requests in a different language then try hosting a gateway file, e.g. a php file that makes the ebay cURL request for you. Your FileMaker file can then use "insert from URL" to your gateway file and then that file can make the ebay request. You can host the gateway file on your filemaker server in the HTTPServer/conf folder or on a webserver elsewhere.

Upvotes: 0

Related Questions