Sign in to participate

Be Kind, Be Helpful

Ask a question, answer a question, and get to know the fine people in the Harvest community.

Forum powered by Altered Beast
This is the user page for Nick Ohrn
Last seen 7 months ago

Nick Ohrn

Avatar

Nick ohrn has not yet entered a bio.

My Website

Avatar

RE: JSON Support for Expenses API Endpoint IN: API and Developers

For anyone who wants to know, the following is what you should post over:

{ "expense": {
	{
	“notes”: “Buy Valentine’s Day chocolates for Harvest”,
	“total_cost”: 11.34,
	“project_id”: 1504605,
	“expense_category_id”: 701315,
	“spent_at”: “Thu, 08 Sep 2011”
	}
}

Notice that total-cost because total_cost and that the “expense” item is inside a pair of braces.

Avatar

RE: JSON Support for Expenses API Endpoint IN: API and Developers

Jon, sent you an email with as much detail as I could muster. Let me know if you need anything else and thanks so much!

Avatar

RE: JSON Support for Expenses API Endpoint IN: API and Developers

I am now getting a different error message (so I’m assuming there is some movement on this issue). As noted above, I was receiving the message:

{
  “error”: {
    “kind”: “UserNotAssigned”,
    “message”: “This expense is missing a project”
 }
}

Now, I am receiving the following message when attempting to use JSON to create an expense:

{
  "error": {
    "kind": "UserNotAssigned",
    "message": "Cannot create record as the User is not assigned to the requested project."
  }
}

This error message appears to be incorrect because the User I am specifying in my authentication string is certainly assigned to the project ID that I am posting. I know this because I made a request to /daily with the same authentication string and received the project ID in the response.

Again, any and all help would be appreciated :)

Avatar

RE: JSON Support for Expenses API Endpoint IN: API and Developers

Just as a note to anyone who sees this, I got this confirmed as a bug by the Harvest developers and hopefully it’ll be fixed soon.

Avatar

RE: JSON Support for Expenses API Endpoint IN: API and Developers

I am working with JSON against the Harvest API and have user authentication, time entry operations, and expense category and expense retrieval working as desired. At this point I am attempting to get expense creation working appropriately but am having a few problems.

If I use the XML method (application/xml as Accept and Content-Type headers, POSTing XML like the sample http://www.getharvest.com/api/expense-tracking) everything works appropriately. However, if I post JSON containing the same information and with the appropriate headers, I get back a JSON error message as follows:

{
“error”: {
“kind”: “UserNotAssigned”,
“message”: “This expense is missing a project”
}
}

The following is the JSON I am posting:

{
“notes”: “Buy Valentine’s Day chocolates for Harvest”,
“total-cost”: 11.34,
“project_id”: 1504605,
“expense_category_id”: 701315,
“spent_at”: “Thu, 08 Sep 2011”
}

I am authenticating correctly given the fact that all other operations exist, but I just cannot get this to work yet. Interestingly, I get the same message when I post the XML without the expense_category_id field in the XML body but, as you can see, I am correctly specifying that field in the JSON.