如何通过“从URL插入” curl选项将邮递员curl代码转换为filemaker pro?

时间:2019-05-06 15:09:31

标签: postman filemaker

我试图将邮递员中有效的curl代码转移到Filemaker,但是我无法使其工作。

以下是邮递员的有效curl代码:

curl -X POST \
  'https://apidev.nationex.com/api/ShippingV2/GetDestinationETA?ShippingID=606200005' \
  -H 'Accept: */*' \
  -H 'Authorization: XXXXXXXXXXXXXXXXX' \
  -H 'Cache-Control: no-cache' \
  -H 'Connection: keep-alive' \
  -H 'Content-Type: application/json' \
  -H 'Host: apidev.nationex.com' \
  -H 'Postman-Token: e9f8cf52-fbe4-4a74-8b49-d03b54c238d6,912db917-0a65-4644-9526-68a062f71e70' \
  -H 'User-Agent: PostmanRuntime/7.11.0' \
  -H 'accept-encoding: gzip, deflate' \
  -H 'cache-control: no-cache' \
  -H 'content-length: 83' \
  -d '{
    "CustomerID":162450,
    "DestPostalCode":"J3Y5T7",
    "PickupDate":"2019-04-29",
}
    '

以下是我放入filemaker curl选项中的代码:

"-X POST \
  'https://apidev.nationex.com/api/ShippingV2/GetDestinationETA?ShippingID=606200005' \
  -H 'Accept: */*' \
  -H 'Authorization: XXXXXXXXXXXXXXXXX' \
  -H 'Cache-Control: no-cache' \
  -H 'Connection: keep-alive' \
  -H 'Content-Type: application/json' \
  -H 'Host: apidev.nationex.com' \
  -H 'Postman-Token: e9f8cf52-fbe4-4a74-8b49-d03b54c238d6,07e38ca7-19a1-49ab-a57d-11c62c398b06' \
  -H 'User-Agent: PostmanRuntime/7.11.0' \
  -H 'accept-encoding: gzip, deflate' \
  -H 'cache-control: no-cache' \
  -H 'content-length: 83' \
  -d '{
    \"CustomerID\":162450,
    \"DestPostalCode\":\"J3Y5T7\",
    \"PickupDate\":\"2019-04-29\",
}
    '"

以下是我在Filemaker中收到的错误消息:

{"Message":"An error has occurred.","ExceptionMessage":"Object reference not set to an instance of an object.","ExceptionType":"System.NullReferenceException","StackTrace":"   at Nat.Dal.DAL.DALWebApiUser.IsTokenValid(HttpRequestMessage _request, Int32 _customerID) in C:\\GIT\\nat.dal\\DAL\\DALWebApiUser.cs:line 257\r\n   at NationexWebApi.Controllers.ShippingV2Controller.GetDestinationETA(DTOETARequest _request) in C:

有人可以在这里给我一些见解吗?非常感谢!

3 个答案:

答案 0 :(得分:1)

您收到的错误是来自API,而不是FileMaker。

您无需在cURL选项中指定URL,而仅指定其他参数。

您可能希望选择--show-error

您应该了解FileMaker cURL的工作方式差异:https://fmhelp.filemaker.com/help/16/fmp/en/index.html#page/FMP_Help/curl-options.html

此外,您不需要转义换行符,但是您可能希望在单引号和双引号之间混合使用引号样式。

也许是这样(虽然我尝试时会超时)

"-H \"Accept: */*\" 
-H \"Authorization: XXXXXXXXXXXXXXXXX\" 
-H \"Cache-Control: no-cache\" 
-H \"Connection: keep-alive\" 
-H \"Content-Type: application/json\" 
-H \"Host: apidev.nationex.com\" 
-H \"Postman-Token: e9f8cf52-fbe4-4a74-8b49-d03b54c238d6,07e38ca7-19a1-49ab-a57d-11c62c398b06\" 
-H \"User-Agent: PostmanRuntime/7.11.0\" 
-H \"accept-encoding: gzip, deflate\" 
-H \"cache-control: no-cache\" 
-H \"content-length: 83\" 
-d \"{
    \"CustomerID\":162450,
    \"DestPostalCode\":\"J3Y5T7\",
    \"PickupDate\":\"2019-04-29\",
}\""

API站点可能已损坏。尝试设置自己的Web服务,您可以在其中检查传入的请求,或使用httpProxy检查请求。

答案 1 :(得分:0)

尝试使用Geist Interactive的Generator代替Postman。您只需复制粘贴FileMaker代码即可。

答案 2 :(得分:0)

最后,我设法用Nationex API建立了连接。这是Filemaker Pro中可使用的cURL选项的样子:

“-H \”授权:XXXXXXXXXXXXXXXXX \“ -H \”内容类型:application / json \“ -d @ $ josn”

感谢大家的帮助!