1
私はかなり新しいGoogle Apps Script
です。私はパブリックAPIからデータを取得するためのスクリプトを作成しようとしています。私は、パラメータを渡す必要がありますが、APIのdocumenation情報は、このようにアクセスできることを示しApps Script
AppsスクリプトのパラメータをcUrlに渡す
でそれを行う方法を見つけ出すことはできません。
curl -H "Content-Type: application/json" -X GET
--header "X-PW-AccessToken:<TOKEN>" \
--header "X-PW-Application:developer_api" \
--header "X-PW-UserEmail:<USER_EMAIL_ADDRESS>" \
-d '{"name":"My Lead","email":{"email":"[email protected]","category":"work"}}'
私はApps Script
でこの機能を設定しています。
function myFunction() {
var url = "https://api.prosperworks.com/developer_api/v1/leads/search";
var fetchParameters = {};
fetchParameters.method = "post";
fetchParameters.contentType = "application/json";
fetchParameters.headers = {
"X-PW-AccessToken": <TOKEN>,
"X-PW-Application": "developer_api",
"X-PW-UserEmail": <USER_EMAIL_ADDRESS>
};
fetchParameters.muteHttpExceptions = true;
fetchParameters.payload = {"name":"My Lead","email":{"email":"[email protected]","category":"work"}};
var response = UrlFetchApp.fetch(url, fetchParameters);
var dataAll = JSON.parse(response.getContentText());
}
それが値を渡す方法であるように見えたので、私はfetchParameters.payload
を追加しましたが、私はJSON
を解析すると、このエラーが出る:
Execution failed: SyntaxError: Unexpected token: <
私がfetchParameters.payload
をコメントアウトすると、正常に動作しますが、どのパラメータも(明らかに)考慮しません。
私は試してみました:fetchParameters.d
、fetchParameters.data
などがありますが、何も動作していないようです。