首页 > 解决方案 > 如何在 OpenRefine 中使用 cURL?

问题描述

我正在尝试连接到 OpenRefine 上的 API,该 API 仅适用于带有 OAth 的 cURL 请求,他们给出了以下示例:

curl --location --request POST 'https://apitest.api.com/' \

--header 'Content-Type: application/json' \

--header 'Accept: application/json' \

--header 'Authorization: Bearer ***************' \

--data-raw '{

  "Name": {

    "FirstName": "BOB",

    "LastName": "SMITH"

  },

  "Address": {

    "Addr1": "123 23RD ST",

    "City": "NEW YORK",

    "State": "NY",

    "Zip": "10010"

  }

}'

我改为(使用GREL)

curl --location --request POST 'https://apitest.api.com/' \

--header 'Content-Type: application/json' \

--header 'Accept: application/json' \

--header 'Authorization: Bearer ***************' \

--data-raw '{

  "Name": {

    "FirstName": cells['FirstName'].value,

    "LastName": cells['LastName'].value

  },

  "Address": {

    "Addr1": cells['StreetAddress'].value,

    "City": cells['City'].value,

    "State": cells['State'].value,

    "Zip": cells['Zip'].value

  }

}'

这给了我一个Parsing error at offset 7: Bad negative number

我也将Authorization: Bearer ***************and放在了Accept: application/jsonHTTP headers区域,也没有运气。

我也试过:

curl -X POST --header "Content-Type: application/json" --header "Accept: application/json" --header "Authorization: Bearer ******" -d "{
  \"Name\": {
    \"FirstName\": \" + cells['FirstName'].value + \",
    \"LastName\": \" + cells['LastName'].value + \"
  },
  \"Address\": {
    \"Addr1\": \" + cells['Street'].value + \",
    \"City\": \" + cells['City'].value + \",
    \"State\": \" + cells['State'].value + \",
    \"Zip\": \" + cells['Zip'].value + \"
  }
}" "https://apitest.api.com/"

在我的控制台中使用显式数据。(我不再收到解析错误,但我也没有得到任何其他信息。)

谢谢!

标签: curlopenrefine

解决方案


推荐阅读