Hi. I’ve literally just started with the FreeAgent API and I seem to have fallen at the first hurdle.
I’ve registered as a developer, set up my app, I’ve got an OAuth playground going and I’m talking nicely to my sandbox FreeAgent account. The “https://api.sandbox.freeagent.com/v2/company” get command is working.
However, I can’t seem to create an invoice from the OAuth playground. I don’t know what I’m missing.
I am sending the below (copied and pasted from API docs) as a POST request to https://api.sandbox.freeagent.com/v2/invoices. And nothing seems to happen. Below the request body copied and pasted below I’ve pasted the request / response from OAuth Playground. Can anybody tell me what I’m missing?
Please note anything that looks like a link I’ve had to remove because this is my first post and I can’t send more than 2 links.
Thank you
{ “invoice”:
{
“contact”:“https://api.freeagent.com/v2/contacts/2”,
“dated_on”:“2001-12-12”,
“due_on”:“2001-12-17”,
“reference”:“003”,
“currency”:“GBP”,
“exchange_rate”:“1.0”,
“net_value”:“0.0”,
“total_value”: “200.0”,
“paid_value”: “0.0”,
“due_value”: “200.0”,
“status”:“Draft”,
“omit_header”:false,
“always_show_bic_and_iban”: false,
“send_thank_you_emails”:false,
“send_reminder_emails”:false,
“send_new_invoice_emails”: false,
“bank_account”: “https://api.freeagent.com/v2/bank_accounts/1”,
“payment_terms_in_days”:5,
“payment_methods”: {
“paypal”: false,
“stripe”: false,
},
“created_at”:“2011-08-29T00:00:00Z”,
“updated_at”:“2011-08-29T00:00:00Z”,
“invoice_items”:[
{
“description”:“Test InvoiceItem”,
“item_type”:“Hours”,
“price”:“0.0”,
“quantity”:“0.0”
}
]
}
}
Request / Response from OAuth Playground:
POST /v2/invoices HTTP/1.1
Host: api.sandbox.freeagent.com
Content-length: 924
Content-type: application/json
Authorization: Bearer 1JFuZsmLPKQIs73VNCEKmJq95B3QMb4sm6evrOX4a
{ “invoice”:
{
“contact”:“https://api.freeagent.com/v2/contacts/2”,
“dated_on”:“2001-12-12”,
“due_on”:“2001-12-17”,
“reference”:“003”,
“currency”:“GBP”,
“exchange_rate”:“1.0”,
“net_value”:“0.0”,
“total_value”: “200.0”,
“paid_value”: “0.0”,
“due_value”: “200.0”,
“status”:“Draft”,
“omit_header”:false,
“always_show_bic_and_iban”: false,
“send_thank_you_emails”:false,
“send_reminder_emails”:false,
“send_new_invoice_emails”: false,
“bank_account”: “https://api.freeagent.com/v2/bank_accounts/1”,
“payment_terms_in_days”:5,
“payment_methods”: {
“paypal”: false,
“stripe”: false,
},
“created_at”:“2011-08-29T00:00:00Z”,
“updated_at”:“2011-08-29T00:00:00Z”,
“invoice_items”:[
{
“description”:“Test InvoiceItem”,
“item_type”:“Hours”,
“price”:“0.0”,
“quantity”:“0.0”
}
]
}
}
HTTP/1.1 302 Found
X-request-id: 24fa7764-fc20-4e33-af7d-3015d1b876ca
X-xss-protection: 1; mode=block
X-rev: e0e3f1003793fc8a36d5f5c4ea04d8ea4f70ad2a
Content-security-policy: default-src data: ‘unsafe-eval’ ‘unsafe-inline’ *; plugin-types application/x-shockwave-flash; script-src ‘self’ ‘unsafe-eval’ ‘unsafe-inline’ data: *.google-analytics.com *.googleapis.com *.optimizely.com api.stripe.com bam.nr-data.net connect.facebook.net freeagent-assets.s3.amazonaws.com freeagent-videos.s3.amazonaws.com googleads.g.doubleclick.net js.honeybadger.io js.stripe.com js-agent.newrelic.com p.typekit.net sdr.totango.com use.typekit.com use.typekit.net website.freeagent.com yyy.freeagent.com yyy.google.co.uk yyy.google.com yyy.googleadservices.com yyy.googletagmanager.com tagmanager.google.com yyy.snapengage.com; report-uri /csp_violations
Transfer-encoding: chunked
Strict-transport-security: max-age=31536000;
Vary: Origin
X-runtime: 0.003166
Server: nginx
Connection: keep-alive
Location: xxxx://api.sandbox.freeagent.com/sessions/new
Date: Sat, 17 Feb 2018 19:52:57 GMT
X-frame-options: SAMEORIGIN
Content-type: text/html; charset=utf-8
X-content-type-options: nosniff, nosniff
X-host: web1-gc