HTTP 500 Internal Server Error - Uploading Expenses

Hi,
I’m testing some JSON expenses uploads on the sandbox using curl (and the
Oauth Palyground) but I keep getting HTTP 500 errors.
Here’s the curl script I’m using and the response I’m getting:

$ curl https://api.sandbox.freeagent.com/v2/expenses \

-H “Authorization: Bearer TOKEN-GENERATED-FROM-OAUTH-PLAYGROUND”
-H “Accept: application/json”
-H “Content-Type: application/json”
-X POST
-d ‘{“expense”: {“category”:
https://api.sandbox.freeagent.com/v2/categories/XXXXX”, “dated_on”:
“2013-07-15”, “user”: “https://api.sandbox.freeagent.com/v2/users/XXX”,
“gross_value”: 108.99, “description”: “Overnight Subsistence”}}’

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.

I checked the JSON at jsonlint.com and it validates fine. I’ve also double
checked the categories and users (removed here).

The token is fine too because I can successfully get the company data…

$ curl https://api.sandbox.freeagent.com/v2/company -H “Authorization:
Bearer TOKEN-GENERATED-FROM-OAUTH-PLAYGROUND” -H “Accept: application/json”
-H “Content-Type: application/json” -X GET
{“company”:{“url”:“https://api.sandbox.freeagent.com/v2/company",“name”:“SomeTestCo”,“subdomain”:“SomeSubDomain”,“type”:“UniversalCompany”,“currency”:“EUR”,“mileage_units”:“km”,“company_start_date”:“2013-01-01”,“freeagent_start_date”:“2013-01-01”,“first_accounting_year_end”:“2013-12-31”,“sales_tax_registration_status”:“Registered”,“sales_tax_name”:“VAT”,“sales_tax_registration_number”:“1234567”,“sales_tax_rates”:[“23.0”,“13.5”,“0.0”],“sales_tax_is_value_added”:true,"supports_auto_sales_tax_on_purchases”:false}}

Has anyone got suggestions as to what could be triggering the 500 error.
Even running curl in verbose mode doesn’t offer much more information
except that the data is being uploaded successfully.

Thanks,
Patrick

Hi John,
Thanks for looking at the issue. I tried again, copying the curl command
you used and changing the category/user and came up with the same results.
Here’s what I’m posting…

curl https://api.sandbox.freeagent.com/v2/expenses
-H “Authorization: Bearer ACCESS_TOKEN”
-H “Accept: application/json”
-H “Content-Type: application/json”
-X POST
-d ‘{“expense”: {“category”: "
https://api.sandbox.freeagent.com/v2/categories/15772", “dated_on”:
“2013-09-09”, “user”: “https://api.sandbox.freeagent.com/v2/users/377”,
“gross_value”: 108.99, “description”: “Overnight Subsistence”}}’

BTW GET requests with teh access token I’m using are working fine.

PatrickOn Tuesday, 10 September 2013 15:41:06 UTC+1, John Siladie wrote:

Hi Patrick,

Sorry for not getting back to you sooner.

I was able to get an expense created using curl doing based on your
example:

➜ curl https://api.sandbox.freeagent.com/v2/expenses
-H “Authorization: Bearer AUTH_TOKEN”
-H “Accept: application/json”
-H “Content-Type: application/json”
-X POST \

-d ‘{“expense”: {“category”: "
https://api.sandbox.freeagent.com/v2/categories/268", “dated_on”:
“2013-09-09”, “user”: “https://api.sandbox.freeagent.com/v2/users/378”,
“gross_value”: 108.99, “description”: “Overnight Subsistence”}}’
{“expense”:{“url”:"https://api.sandbox.freeagent.com/v2/expenses/4119
",“user”:“https://api.sandbox.freeagent.com/v2/users/378",“category”:"
https://api.sandbox.freeagent.com/v2/categories/268",“dated_on”:“2013-09-09”,“currency”:“USD”,“gross_value”:“108.99”,“native_gross_value”:“108.99”,“description”:"Overnight
Subsistence”,“updated_at”:“2013-09-10T14:32:07Z”,“created_at”:“2013-09-10T14:32:07Z”}}%

Can you double check that the category and user you are using in your POST
exists and is active. Also, make sure you’re pointing to the sandbox for
all of your calls including the category and user if this is indeed a
sandbox call.

Let me know if this helps.

Thanks,
John

On Friday, September 6, 2013 3:37:45 AM UTC-6, Patrick O’Connor wrote:

Hi,
I’m testing some JSON expenses uploads on the sandbox using curl (and the
Oauth Palyground) but I keep getting HTTP 500 errors.
Here’s the curl script I’m using and the response I’m getting:

$ curl https://api.sandbox.freeagent.com/v2/expenses \

-H “Authorization: Bearer TOKEN-GENERATED-FROM-OAUTH-PLAYGROUND”
-H “Accept: application/json”
-H “Content-Type: application/json”
-X POST
-d ‘{“expense”: {“category”: "
https://api.sandbox.freeagent.com/v2/categories/XXXXX", “dated_on”:
“2013-07-15”, “user”: “https://api.sandbox.freeagent.com/v2/users/XXX”,
“gross_value”: 108.99, “description”: “Overnight Subsistence”}}’

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.

I checked the JSON at jsonlint.com and it validates fine. I’ve also
double checked the categories and users (removed here).

The token is fine too because I can successfully get the company data…

$ curl https://api.sandbox.freeagent.com/v2/company -H “Authorization:
Bearer TOKEN-GENERATED-FROM-OAUTH-PLAYGROUND” -H “Accept: application/json”
-H “Content-Type: application/json” -X GET
{“company”:{“url”:"https://api.sandbox.freeagent.com/v2/company
",“name”:“SomeTestCo”,“subdomain”:“SomeSubDomain”,“type”:“UniversalCompany”,“currency”:“EUR”,“mileage_units”:“km”,“company_start_date”:“2013-01-01”,“freeagent_start_date”:“2013-01-01”,“first_accounting_year_end”:“2013-12-31”,“sales_tax_registration_status”:“Registered”,“sales_tax_name”:“VAT”,“sales_tax_registration_number”:“1234567”,“sales_tax_rates”:[“23.0”,“13.5”,“0.0”],“sales_tax_is_value_added”:true,“supports_auto_sales_tax_on_purchases”:false}}

Has anyone got suggestions as to what could be triggering the 500 error.
Even running curl in verbose mode doesn’t offer much more information
except that the data is being uploaded successfully.

Thanks,
Patrick

Hi Patrick,

Sorry for not getting back to you sooner.

I was able to get an expense created using curl doing based on your example:

➜ curl https://api.sandbox.freeagent.com/v2/expenses
-H “Authorization: Bearer AUTH_TOKEN”
-H “Accept: application/json”
-H “Content-Type: application/json”
-X POST \

-d ‘{“expense”: {“category”:
https://api.sandbox.freeagent.com/v2/categories/268”, “dated_on”:
“2013-09-09”, “user”: “https://api.sandbox.freeagent.com/v2/users/378”,
“gross_value”: 108.99, “description”: “Overnight Subsistence”}}’
{“expense”:{“url”:“https://api.sandbox.freeagent.com/v2/expenses/4119",“user”:“https://api.sandbox.freeagent.com/v2/users/378”,“category”:“https://api.sandbox.freeagent.com/v2/categories/268”,“dated_on”:“2013-09-09”,“currency”:“USD”,“gross_value”:“108.99”,“native_gross_value”:“108.99”,“description”:"Overnight
Subsistence”,“updated_at”:“2013-09-10T14:32:07Z”,“created_at”:“2013-09-10T14:32:07Z”}}%

Can you double check that the category and user you are using in your POST
exists and is active. Also, make sure you’re pointing to the sandbox for
all of your calls including the category and user if this is indeed a
sandbox call.

Let me know if this helps.

Thanks,
JohnOn Friday, September 6, 2013 3:37:45 AM UTC-6, Patrick O’Connor wrote:

Hi,
I’m testing some JSON expenses uploads on the sandbox using curl (and the
Oauth Palyground) but I keep getting HTTP 500 errors.
Here’s the curl script I’m using and the response I’m getting:

$ curl https://api.sandbox.freeagent.com/v2/expenses \

-H “Authorization: Bearer TOKEN-GENERATED-FROM-OAUTH-PLAYGROUND”
-H “Accept: application/json”
-H “Content-Type: application/json”
-X POST
-d ‘{“expense”: {“category”: "
https://api.sandbox.freeagent.com/v2/categories/XXXXX", “dated_on”:
“2013-07-15”, “user”: “https://api.sandbox.freeagent.com/v2/users/XXX”,
“gross_value”: 108.99, “description”: “Overnight Subsistence”}}’

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.

I checked the JSON at jsonlint.com and it validates fine. I’ve also
double checked the categories and users (removed here).

The token is fine too because I can successfully get the company data…

$ curl https://api.sandbox.freeagent.com/v2/company -H “Authorization:
Bearer TOKEN-GENERATED-FROM-OAUTH-PLAYGROUND” -H “Accept: application/json”
-H “Content-Type: application/json” -X GET
{“company”:{“url”:"https://api.sandbox.freeagent.com/v2/company
",“name”:“SomeTestCo”,“subdomain”:“SomeSubDomain”,“type”:“UniversalCompany”,“currency”:“EUR”,“mileage_units”:“km”,“company_start_date”:“2013-01-01”,“freeagent_start_date”:“2013-01-01”,“first_accounting_year_end”:“2013-12-31”,“sales_tax_registration_status”:“Registered”,“sales_tax_name”:“VAT”,“sales_tax_registration_number”:“1234567”,“sales_tax_rates”:[“23.0”,“13.5”,“0.0”],“sales_tax_is_value_added”:true,“supports_auto_sales_tax_on_purchases”:false}}

Has anyone got suggestions as to what could be triggering the 500 error.
Even running curl in verbose mode doesn’t offer much more information
except that the data is being uploaded successfully.

Thanks,
Patrick

Yep that sorted it. Once I replaced the category ID with the category
nominal code for the url it worked perfectly.
Thanks for working through it with me.

PatrickOn Wednesday, 11 September 2013 22:18:28 UTC+1, Ben wrote:

Hi Patrick,

There is no category with that nominal code for your company. The value
you supplied in the URL (15772) is the ID. You can get the nominal code
from https://api.sandbox.freeagent.com/v2/categories.

To check if you have the right nominal code, you can GET
https://api.sandbox.freeagent.com/v2/categories/NOMINAL_CODE

Our documentation is misleading in this case. We also should provide an
error message instead of just returning 500.

Does that help?

Ben

On Wednesday, 11 September 2013 13:55:08 UTC-7, Patrick O’Connor wrote:

Hi John,
Thanks for looking at the issue. I tried again, copying the curl command
you used and changing the category/user and came up with the same results.
Here’s what I’m posting…

curl https://api.sandbox.freeagent.com/v2/expenses
-H “Authorization: Bearer ACCESS_TOKEN”
-H “Accept: application/json”
-H “Content-Type: application/json”
-X POST
-d ‘{“expense”: {“category”: "
https://api.sandbox.freeagent.com/v2/categories/15772", “dated_on”:
“2013-09-09”, “user”: “https://api.sandbox.freeagent.com/v2/users/377”,
“gross_value”: 108.99, “description”: “Overnight Subsistence”}}’

BTW GET requests with teh access token I’m using are working fine.

Patrick

On Tuesday, 10 September 2013 15:41:06 UTC+1, John Siladie wrote:

Hi Patrick,

Sorry for not getting back to you sooner.

I was able to get an expense created using curl doing based on your
example:

➜ curl https://api.sandbox.freeagent.com/v2/expenses
-H “Authorization: Bearer AUTH_TOKEN”
-H “Accept: application/json”
-H “Content-Type: application/json”
-X POST \

-d ‘{“expense”: {“category”: "
https://api.sandbox.freeagent.com/v2/categories/268", “dated_on”:
“2013-09-09”, “user”: “https://api.sandbox.freeagent.com/v2/users/378”,
“gross_value”: 108.99, “description”: “Overnight Subsistence”}}’
{“expense”:{“url”:"https://api.sandbox.freeagent.com/v2/expenses/4119
",“user”:“https://api.sandbox.freeagent.com/v2/users/378",“category”:"
https://api.sandbox.freeagent.com/v2/categories/268",“dated_on”:“2013-09-09”,“currency”:“USD”,“gross_value”:“108.99”,“native_gross_value”:“108.99”,“description”:"Overnight
Subsistence”,“updated_at”:“2013-09-10T14:32:07Z”,“created_at”:“2013-09-10T14:32:07Z”}}%

Can you double check that the category and user you are using in your
POST exists and is active. Also, make sure you’re pointing to the sandbox
for all of your calls including the category and user if this is indeed a
sandbox call.

Let me know if this helps.

Thanks,
John

On Friday, September 6, 2013 3:37:45 AM UTC-6, Patrick O’Connor wrote:

Hi,
I’m testing some JSON expenses uploads on the sandbox using curl (and
the Oauth Palyground) but I keep getting HTTP 500 errors.
Here’s the curl script I’m using and the response I’m getting:

$ curl https://api.sandbox.freeagent.com/v2/expenses \

-H “Authorization: Bearer TOKEN-GENERATED-FROM-OAUTH-PLAYGROUND”
-H “Accept: application/json”
-H “Content-Type: application/json”
-X POST
-d ‘{“expense”: {“category”: "
https://api.sandbox.freeagent.com/v2/categories/XXXXX", “dated_on”:
“2013-07-15”, “user”: “https://api.sandbox.freeagent.com/v2/users/XXX”,
“gross_value”: 108.99, “description”: “Overnight Subsistence”}}’

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.

I checked the JSON at jsonlint.com and it validates fine. I’ve also
double checked the categories and users (removed here).

The token is fine too because I can successfully get the company
data…

$ curl https://api.sandbox.freeagent.com/v2/company -H “Authorization:
Bearer TOKEN-GENERATED-FROM-OAUTH-PLAYGROUND” -H “Accept: application/json”
-H “Content-Type: application/json” -X GET
{“company”:{“url”:"https://api.sandbox.freeagent.com/v2/company
",“name”:“SomeTestCo”,“subdomain”:“SomeSubDomain”,“type”:“UniversalCompany”,“currency”:“EUR”,“mileage_units”:“km”,“company_start_date”:“2013-01-01”,“freeagent_start_date”:“2013-01-01”,“first_accounting_year_end”:“2013-12-31”,“sales_tax_registration_status”:“Registered”,“sales_tax_name”:“VAT”,“sales_tax_registration_number”:“1234567”,“sales_tax_rates”:[“23.0”,“13.5”,“0.0”],“sales_tax_is_value_added”:true,“supports_auto_sales_tax_on_purchases”:false}}

Has anyone got suggestions as to what could be triggering the 500
error. Even running curl in verbose mode doesn’t offer much more
information except that the data is being uploaded successfully.

Thanks,
Patrick

Hi Patrick,

There is no category with that nominal code for your company. The value you
supplied in the URL (15772) is the ID. You can get the nominal code from
https://api.sandbox.freeagent.com/v2/categories.

To check if you have the right nominal code, you can GET
https://api.sandbox.freeagent.com/v2/categories/NOMINAL_CODE

Our documentation is misleading in this case. We also should provide an
error message instead of just returning 500.

Does that help?

BenOn Wednesday, 11 September 2013 13:55:08 UTC-7, Patrick O’Connor wrote:

Hi John,
Thanks for looking at the issue. I tried again, copying the curl command
you used and changing the category/user and came up with the same results.
Here’s what I’m posting…

curl https://api.sandbox.freeagent.com/v2/expenses
-H “Authorization: Bearer ACCESS_TOKEN”
-H “Accept: application/json”
-H “Content-Type: application/json”
-X POST
-d ‘{“expense”: {“category”: "
https://api.sandbox.freeagent.com/v2/categories/15772", “dated_on”:
“2013-09-09”, “user”: “https://api.sandbox.freeagent.com/v2/users/377”,
“gross_value”: 108.99, “description”: “Overnight Subsistence”}}’

BTW GET requests with teh access token I’m using are working fine.

Patrick

On Tuesday, 10 September 2013 15:41:06 UTC+1, John Siladie wrote:

Hi Patrick,

Sorry for not getting back to you sooner.

I was able to get an expense created using curl doing based on your
example:

➜ curl https://api.sandbox.freeagent.com/v2/expenses
-H “Authorization: Bearer AUTH_TOKEN”
-H “Accept: application/json”
-H “Content-Type: application/json”
-X POST \

-d ‘{“expense”: {“category”: "
https://api.sandbox.freeagent.com/v2/categories/268", “dated_on”:
“2013-09-09”, “user”: “https://api.sandbox.freeagent.com/v2/users/378”,
“gross_value”: 108.99, “description”: “Overnight Subsistence”}}’
{“expense”:{“url”:"https://api.sandbox.freeagent.com/v2/expenses/4119
",“user”:“https://api.sandbox.freeagent.com/v2/users/378",“category”:"
https://api.sandbox.freeagent.com/v2/categories/268",“dated_on”:“2013-09-09”,“currency”:“USD”,“gross_value”:“108.99”,“native_gross_value”:“108.99”,“description”:"Overnight
Subsistence”,“updated_at”:“2013-09-10T14:32:07Z”,“created_at”:“2013-09-10T14:32:07Z”}}%

Can you double check that the category and user you are using in your
POST exists and is active. Also, make sure you’re pointing to the sandbox
for all of your calls including the category and user if this is indeed a
sandbox call.

Let me know if this helps.

Thanks,
John

On Friday, September 6, 2013 3:37:45 AM UTC-6, Patrick O’Connor wrote:

Hi,
I’m testing some JSON expenses uploads on the sandbox using curl (and
the Oauth Palyground) but I keep getting HTTP 500 errors.
Here’s the curl script I’m using and the response I’m getting:

$ curl https://api.sandbox.freeagent.com/v2/expenses \

-H “Authorization: Bearer TOKEN-GENERATED-FROM-OAUTH-PLAYGROUND”
-H “Accept: application/json”
-H “Content-Type: application/json”
-X POST
-d ‘{“expense”: {“category”: "
https://api.sandbox.freeagent.com/v2/categories/XXXXX", “dated_on”:
“2013-07-15”, “user”: “https://api.sandbox.freeagent.com/v2/users/XXX”,
“gross_value”: 108.99, “description”: “Overnight Subsistence”}}’

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.

I checked the JSON at jsonlint.com and it validates fine. I’ve also
double checked the categories and users (removed here).

The token is fine too because I can successfully get the company data…

$ curl https://api.sandbox.freeagent.com/v2/company -H “Authorization:
Bearer TOKEN-GENERATED-FROM-OAUTH-PLAYGROUND” -H “Accept: application/json”
-H “Content-Type: application/json” -X GET
{“company”:{“url”:"https://api.sandbox.freeagent.com/v2/company
",“name”:“SomeTestCo”,“subdomain”:“SomeSubDomain”,“type”:“UniversalCompany”,“currency”:“EUR”,“mileage_units”:“km”,“company_start_date”:“2013-01-01”,“freeagent_start_date”:“2013-01-01”,“first_accounting_year_end”:“2013-12-31”,“sales_tax_registration_status”:“Registered”,“sales_tax_name”:“VAT”,“sales_tax_registration_number”:“1234567”,“sales_tax_rates”:[“23.0”,“13.5”,“0.0”],“sales_tax_is_value_added”:true,“supports_auto_sales_tax_on_purchases”:false}}

Has anyone got suggestions as to what could be triggering the 500 error.
Even running curl in verbose mode doesn’t offer much more information
except that the data is being uploaded successfully.

Thanks,
Patrick