Posting a new expense gives me a 500 error

I develop checkeeper.com, and at the request of some of our users, we’re
adding support for Free Agent. People can grab all their bills through the
API and then print their own checks or have us mail checks on their behalf.

I’m running into trouble with the Expenses portion of the API (maybe more,
but i haven’t gotten too far yet.) Every time I try to post a new expense,
I get a 500 server error. My guess is that I’m just missing something in
the json payload, but all the other things i’ve interfaced with (getting
projects and categories for example) give me an error from the API, not the
server.

Here’s the info about my request. It’s a PHP application using cURL.

POST https://api.freeagent.com/v2/expenses
Headers: Content-Type: application/json,
Accept: application/json,
Authorization: Bearer [my access token that works for all GETS]

JSON payload:

{“expenses”:{“user”:304968,“gross_value”:“25.00”,“dated_on”:"2014-08-15
",“category”:“359”,“description”:“Paid by Checkeeper Check #1541
https://support.freeagent.com/requests/1541”}}

And the response:

500 Internal Server Error

If you are the administrator of this website, then please read this web application's log file and/or the web server's log file to find out what went wrong.

Any information or ideas anyone has would be greatly appreciated.

Thanks!

Hi Jeffrey,

Looking at the payload you’re sending you’ve pluralised the top level
“expenses” root node in the JSON when we’re actually expecting it to be
using the “expense” key. You’re also sending the user ID and category as
numbers instead of as a URL. If you change your payload to this does it
work?

{
“expense”: {
“user”: “https://api.freeagent.com/v2/users/304968”,
“gross_value”: “25.00”,
“dated_on”: “2014-08-15”,
“category”: “https://api.freeagent.com/v2/categories/359”,
“description”: “Paid by Checkeeper Check #1541
}
}

Regards,
Harry MillsOn Fri, Aug 15, 2014 at 7:51 PM, Jeffrey Meagher jameaghe@gmail.com wrote:

I develop checkeeper.com, and at the request of some of our users, we’re
adding support for Free Agent. People can grab all their bills through the
API and then print their own checks or have us mail checks on their behalf.

I’m running into trouble with the Expenses portion of the API (maybe more,
but i haven’t gotten too far yet.) Every time I try to post a new expense,
I get a 500 server error. My guess is that I’m just missing something in
the json payload, but all the other things i’ve interfaced with (getting
projects and categories for example) give me an error from the API, not the
server.

Here’s the info about my request. It’s a PHP application using cURL.

POST https://api.freeagent.com/v2/expenses
Headers: Content-Type: application/json,
Accept: application/json,
Authorization: Bearer [my access token that works for all GETS]

JSON payload:

{“expenses”:{“user”:304968,“gross_value”:“25.00”,“dated_on”:"2014-08-15
",“category”:“359”,“description”:“Paid by Checkeeper Check #1541
https://support.freeagent.com/requests/1541”}}

And the response:

500 Internal Server Error

If you are the administrator of this website, then please read this web application's log file and/or the web server's log file to find out what went wrong.

Any information or ideas anyone has would be greatly appreciated.

Thanks!


You received this message because you are subscribed to the Google Groups
“FreeAgent API” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to freeagent_api+unsubscribe@googlegroups.com.
To post to this group, send email to freeagent_api@googlegroups.com.
Visit this group at http://groups.google.com/group/freeagent_api.
For more options, visit https://groups.google.com/d/optout.

Harry,

Thank you so much for your help. It worked perfectly after using the
“Expense” key and then using the full URLs. I must have missed the part in
the docs where it said to use a full URL instead of just an ID.

-JeffOn Monday, August 18, 2014 3:04:36 AM UTC-5, Harry wrote:

Hi Jeffrey,

Looking at the payload you’re sending you’ve pluralised the top level
“expenses” root node in the JSON when we’re actually expecting it to be
using the “expense” key. You’re also sending the user ID and category as
numbers instead of as a URL. If you change your payload to this does it
work?

{
“expense”: {
“user”: “https://api.freeagent.com/v2/users/304968”,
“gross_value”: “25.00”,
“dated_on”: “2014-08-15”,
“category”: “https://api.freeagent.com/v2/categories/359”,
“description”: “Paid by Checkeeper Check #1541
}
}


Regards,
Harry Mills

On Fri, Aug 15, 2014 at 7:51 PM, Jeffrey Meagher <jame...@gmail.com <javascript:>> wrote:

I develop checkeeper.com, and at the request of some of our users, we’re
adding support for Free Agent. People can grab all their bills through the
API and then print their own checks or have us mail checks on their behalf.

I’m running into trouble with the Expenses portion of the API (maybe
more, but i haven’t gotten too far yet.) Every time I try to post a new
expense, I get a 500 server error. My guess is that I’m just missing
something in the json payload, but all the other things i’ve interfaced
with (getting projects and categories for example) give me an error from
the API, not the server.

Here’s the info about my request. It’s a PHP application using cURL.

POST https://api.freeagent.com/v2/expenses
Headers: Content-Type: application/json,
Accept: application/json,
Authorization: Bearer [my access token that works for all GETS]

JSON payload:

{“expenses”:{“user”:304968,“gross_value”:“25.00”,“dated_on”:"2014-08-15
",“category”:“359”,“description”:“Paid by Checkeeper Check #1541
https://support.freeagent.com/requests/1541”}}

And the response:

500 Internal Server Error

If you are the administrator of this website, then please read this web application's log file and/or the web server's log file to find out what went wrong.

Any information or ideas anyone has would be greatly appreciated.

Thanks!


You received this message because you are subscribed to the Google Groups
“FreeAgent API” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to freeagent_ap...@googlegroups.com <javascript:>.
To post to this group, send email to freeag...@googlegroups.com
<javascript:>.
Visit this group at http://groups.google.com/group/freeagent_api.
For more options, visit https://groups.google.com/d/optout.