API - Email an Invoice

We are trying to use the below API call:

POST https://api.freeagent.com/v2/invoices/:id/send_email

However it is just not working and not returning anything useful I can use
for debugging. Do you have any ideas as to why this would not work or any
tips to get it to work or return a decent error message?

Already seen that support thread with no luck.

Hi Joe,

What is the HTTP status code of the response? Is there anything at all in
the response body?

Thanks,
BenOn Monday, 21 October 2013 08:31:11 UTC-7, Jonathan Barrett wrote:

Hi Joe,

Sorry you’re having trouble here. Can I ask if you have had a look at this
post on sending invoices via email, and if it helps out at all?

Redirecting to Google Groups

Cheers,

-J

No worries. Sorry for the error-led wild-goose chase :slight_smile:

-JOn Thu, Oct 24, 2013 at 12:05 PM, Joe Mallion jdmallion@gmail.com wrote:

Ah ha, brilliant. Thanks for that. Will check it out now and let you know
if this sorts it.


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/groups/opt_out.

Jonathan Barrett, Senior Engineer

FreeAgent: Accounting software, simplified

+44 (0)131 447 0011

Follow us on Twitter: @freeagent https://twitter.com/freeagent

FreeAgent Central Ltd, 40 Torphichen Street, Edinburgh EH3 8JB
Registered in Scotland SC316774

Hi Joe,

I think I can see the 403 errors in our logs. If it’s the logs I’m looking
at, it looks like you’re not passing through the required email details in
order to send the invoice. Can I check that you’re hitting the endpoint:

POST https://api.freeagent.com/v2/invoices/_YOUR_INVOICE_ID_/send_email

with something like the following JSON:

{
“invoice”: {
“email”: {
“to”: “recipient@example.com”,
“from”: “sender@example.com”,
“subject”: “Subject”,
“body”: “Body”
}
}
}

-JOn Thu, Oct 24, 2013 at 10:15 AM, Joe Mallion jdmallion@gmail.com wrote:

We’ve done some testing and the only response we are getting is a 403
Forbidden response header, the body is blank. What’s odd is that it only
does it when trying to access certain services, namely the email invoice,
and any of the ‘Mark invoice as XXX’ requests.


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/groups/opt_out.

Jonathan Barrett, Senior Engineer

FreeAgent: Accounting software, simplified

+44 (0)131 447 0011

Follow us on Twitter: @freeagent https://twitter.com/freeagent

FreeAgent Central Ltd, 40 Torphichen Street, Edinburgh EH3 8JB
Registered in Scotland SC316774

We’ve done some testing and the only response we are getting is a 403
Forbidden response header, the body is blank. What’s odd is that it only
does it when trying to access certain services, namely the email invoice,
and any of the ‘Mark invoice as XXX’ requests.

Hi Joe,

Okay, thanks for taking a look at those threads. We’re seeing a few error
logs which look like they might be from you, where the invoice cannot be
found due to there being no valid invoice ID handed into the request. At
the risk of asking the obvious, can I check that you’re replacing the :id
field with a valid Invoice ID from the account in question, and can I
second Ben’s request for the response you’re receiving from the server?

Cheers,

-JOn Mon, Oct 21, 2013 at 4:54 PM, Joe Mallion jdmallion@gmail.com wrote:

Already seen and tried both those support threads with no luck am afraid


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/groups/opt_out.

Jonathan Barrett, Senior Engineer

FreeAgent: Accounting software, simplified

+44 (0)131 447 0011

Follow us on Twitter: @freeagent https://twitter.com/freeagent

FreeAgent Central Ltd, 40 Torphichen Street, Edinburgh EH3 8JB
Registered in Scotland SC316774

Hi Joe,

Sorry you’re having trouble here. Can I ask if you have had a look at this
post on sending invoices via email, and if it helps out at all?

https://groups.google.com/forum/#!topic/freeagent_api/Y28CSWxEnv4

Cheers,

-J

Hi Joe,

Looking at the invoice itself, it looks like it has no invoice items? This
will make it unsendable until you add some invoice items.

The error you’re getting back is pretty horrible: I’ll look to have that
fixed up and return something a little more usable.

Cheers,

-JOn Thu, Oct 24, 2013 at 11:53 AM, Joe Mallion jdmallion@gmail.com wrote:

Yep we are definitely using the endpoint:
https://api.freeagent.com/v2/invoices/7385599/send_email

We’ve tried it with both empty params:

{“invoice”:{“email”:{}}}

and full ones:

{“invoice”:{“email”:{“to":"emailaddress@domain.com,“from”:"test@Test.com",“subject”:“TEST
INVOICE”,“body”:“TEST”}}}

and still getting the 403 code.

We have been experimenting here: http://www.requestmaker.com/ If you want
to test please make sure it’s set to POST and set the following headers:

Authorization Bearer 1noM3kVe-FAAiNsOsS5w3_HdOotUuT3EB0Ya7ooib

Content-Type application/json

Accept application/json

User-Agent Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2)
Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)


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/groups/opt_out.

Jonathan Barrett, Senior Engineer

FreeAgent: Accounting software, simplified

+44 (0)131 447 0011

Follow us on Twitter: @freeagent https://twitter.com/freeagent

FreeAgent Central Ltd, 40 Torphichen Street, Edinburgh EH3 8JB
Registered in Scotland SC316774

Ah ha, brilliant. Thanks for that. Will check it out now and let you know
if this sorts it.

Yep we are definitely using the endpoint:
https://api.freeagent.com/v2/invoices/7385599/send_email

We’ve tried it with both empty params:

{“invoice”:{“email”:{}}}

and full ones:

{“invoice”:{“email”:{“to”:“emailaddress@domain.com”,“from”:“test@Test.com”,“subject”:“TEST
INVOICE”,“body”:“TEST”}}}

and still getting the 403 code.

We have been experimenting here: http://www.requestmaker.com/ If you want
to test please make sure it’s set to POST and set the following headers:

Authorization Bearer 1noM3kVe-FAAiNsOsS5w3_HdOotUuT3EB0Ya7ooib

Content-Type application/json

Accept application/json

User-Agent Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2)
Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)