Create Bill -> 401 Unauthorised

Hi

I am trying to create a new bill using the FA API. I am getting a 401 Unauthorised error when I do the following:

POST https://api.sandbox.freeagent.com/v2/bills
headers:
{
“Accept”: “application/json”,
“Authorization”: “Bearer …”,
“Content-Type”: “application/json”
}
data:
{
“bill”: {
“contact”: “https://api.sandbox.freeagent.com/v2/contacts/44770”,
“dated_on”: “2018-05-23”,
“due_on”: “2018-06-23”,
“reference”: “X600”,
“total_value”: “201.0”
}
}

When I try https://api.sandbox.freeagent.com/v2/users/me I get “permission_level”: 8 so it seems not a permission problem.
Also get requests work fine so it seems not an authentication problem.

Any suggestions?

Hi, Ron.

From the logs it looks like you were eventually able to make a successful call. You do want “bill” to be the root key of your input. It also looks like you figured out that “category” is required (even though it’s not in the docs - I’ll get that updated).

As for why you were getting a 401 - you shouldn’t be. You weren’t unauthorized, your input was wrong. I’m looking into getting that fixed.

Sorry about that.