我正在尝试使用 REST API 和 triggerIO 将图像文件附加到 Parse 中的模型;但是我不成功。
我收到错误消息:
'{"type":"EXPECTED_FAILURE","content":"{\\"code\\":107,\\"error\\":\\"This endpoint only supports Content-Type: application/json requests, not application/x-www-form-urlencoded.\\"}","statusCode":"400","message":"HTTP error code received from server: 400"} [71.87s]'
这是相关的代码块:
attachImg: (data) ->
uploadData =
"picture": {
"name": data,
"__type": "File"
}
forge.request.ajax
type: "POST",
url: "https://api.parse.com/1/classes/WorkoutLog",
data: uploadData,
dataType: "json"
headers:
"X-Parse-Application-Id": 'MY-APP-ID',
"X-Parse-REST-API-Key": 'MY-REST-API-KEY',
"Content-Type": 'application/json'
success: (data) ->
debug "File attached"
error: (err) ->
debug err