curl POST XML和Harvest API

时间:2011-03-26 20:07:45

标签: xml post curl harvest

Harvest API的以下curl请求正在生成“我们很抱歉,但出现问题”错误。知道我可能做错了什么吗?也许我没有正确格式化XML POST?我已经能够使用API​​成功执行GET请求。我已在下面的代码中替换了我的特定域名和用户帐户信息。

curl https://domain.harvestapp.com/daily/add/ -H 'Content-Type: application/xml' -H 'Accept: application/xml' -u user@domain.com:password --data-urlencode "<request><notes>Test api support</notes><hours>3</hours><project_id type='integer'>1234567</project_id><task_id type='integer'>12345</task_id><spent_at type='date'>Fri, 25 Mar 2011</spent_at></request>"

1 个答案:

答案 0 :(得分:2)

我认为你的格式有点偏,

试试这个:

    curl https://domain.harvestapp.com/daily/add -H 'Accept: application/xml' -H 'Content-Type: application/xml' -u user@example.com:password -X POST -d "<request><notes>Test api support</notes><hours>3</hours><project_id type=\"integer\">12345</project_id><task_id type=\"integer\">23456</task_id><spent_at type=\"date\">Fri, 27 May 2011</spent_at></request>"