Post

4 followers Follow
0
Avatar

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

Adrian Jones

Please sign in to leave a comment.

11 comments

0
Avatar

I would guess the problem is date formatting, Podio needs the date in the ISO8601 format, i.e. 2014-04-09, not 2014-4-9.

Carl-Fredrik Herö 0 votes
0
Avatar

Hi Carl-Fredrik - Thanks for your reply. Good suggestion, but it's not that I'm afraid!

Adrian Jones 0 votes
0
Avatar

I saw some more things you need to try, almost all fields take an array of values (even it's a single value) and dates have start and end date. Example: "deadline-date": [{"start_date": "2014-04-10"}]

Carl-Fredrik Herö 0 votes
0
Avatar

Thanks Carl-Frederik - OK I'll have to have a look at that. Do you know if there is a full listing of the fields/arrays required anywhere? I saw the description for the php object but it's pretty hard to follow.

Adrian Jones 0 votes
0
Avatar

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!

Adrian Jones 0 votes
0
Avatar

Hey! We getting somewhere, not the same error message! I think you need to change the "last update" as well. And the deadline-date needs to be "start_date", not "StartDate".

Carl-Fredrik Herö 0 votes
0
Avatar

You could try to insert one field at a time, that way you can drill down and know which field is triggering the error.

Carl-Fredrik Herö 0 votes
0
Avatar

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.

Adrian Jones 0 votes
0
Avatar

Based on your last error, I would 1) investigate the object you've sending, and 2) verify all required params are provided and not null

Jarrett Barnett 0 votes
0
Avatar

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.

Adrian Jones 0 votes