Create item using Classic ASP
Hi all - I'm a bit of a newbie to this API lark, so I'm hoping someone more knowledgeable will be able to help me out.
I am attempting create a new item in a particular app from an external web service which is built in Classic ASP, hence the php libraries aren't much good for me.
I am creating a JSON object as follows, using VBS JSON 2.0.3 by Tuðrul Topuz:
Set project=jsObject()
Set project("fields")=jsObject()
project("fields")("Title")=varPost
project("fields")("category")=varJType
project("fields")("status")=varJStatus
project("fields")("deadline-date")="2014-4-10"
project("fields")("strategy-reference")=varProject
project("fields")("progress")=10
project("fields")("last-update")="2014-4-9"
project("fields")("responsibly-person")=varResponsible
I am then posting this to the API using the following function, which outputs the resulting response from the API.
jsResponse=project.Flush
response.write update_post(jsResponse)
function update_post(content)
Dim objSvr2HTTP
Set objSvr2HTTP = Server.CreateObject("MSXML2.XMLHTTP")
objSvr2HTTP.open "POST", "https://api.podio.com/item/app/7661778/", false
objSvr2HTTP.setRequestHeader "Content-Type", "application/json"
objSvr2HTTP.setRequestHeader "Authorization", "OAuth2 "&varAccess_Token
objSvr2HTTP.send content
update_post=objSvr2HTTP.responseText
set objSvr2HTTP=nothing
end function
The response I get from the API is as follows:
{"fields":{"Title":"NM131482-Seminars","category":3,"status":2,"deadline-date":"2014-4-10","strategy-reference":2551097,"progress":10,"last-update":"2014-4-9","responsibly-person":659257}}{"error_parameters":{},"error_detail":null,"error_propagate":false,"request":{"url":"http:\/\/api.podio.com\/item\/app\/7661778\/","query_string":"","method":"POST"},"error_description":"Invalid JSON","error":"invalid_value"}
Anybody have any ideas where it's going wrong?
P.S. Authentication seems to be working OK
Cheers
Adrian
-
I know, the documentation on how to format the request could be better. I use https://developers.podio.com/doc/items and https://developers.podio.com/doc/items/add-new-item-22362 to figure out how the data should be formatted. But I do not need to understand it since I'm using the PHP library.
I believe you will soon get some answers from the Podio staff that will clear things up.
-
Thanks again for your help Carl-Frederik. I've now added in an array for the date field, so my JSON now looks like this:
{"fields":{"Title":"NM131482-Seminars","category":3,"status":2,"deadline-date":[{"startDate":"2014-10-04"}],"strategy-reference":2551097,"progress":10,"last-update":"2014-04-09","responsibly-person":659257}}{"error_parameters":{},"error_detail":null,"error_propagate":false,"request":{"url":"http:\/\/api.podio.com\/item\/app\/7661778\/","query_string":"","method":"POST"},"error_description":"Invalid value null (null): must be object","error":"invalid_value"}
But as you can see, it's still failing.
Anyone from Podio - feel free to jump in any time!
-
Thanks for your great suggestions - I corrected the the start date syntax, but still no good. The "last update" field is actually just a text field in the target app, so I kept that the way it is. Following your second suggestion, I dropped all the fields except the "Title" and it still fails, which means there must be something fundamentally wrong with my approach. I'm going to escalated this to a support ticket. If I get anywhere, I will post the answer here for the benefit of everyone.
-
Bit disappointed to learn that Podio does not support API problems. What would be REALLY helpful for me is if someone could post an example of a well-formed JSON post so I can see exactly what the API is expecting to see. From the error message I'm getting, it's clearly not seeing the post as an object in the correct format. I am pretty much stumped with this now and could really do with some help from the wider community.
Please sign in to leave a comment.
Comments
11 comments