Updating Contacts with PHP CURL (PUT)

Hi Tim,

You definitely need to wrap the json hash in an outer “contact” hash and
it’s not necessary to specify all parameters - just the ones you want to
change e.g:

PUT /v2/contacts/xxx
User-Agent: useragent
Host: api.freeagent.com
Accept: application/json
Content-type: application/json
Authorization: OAuth MY_TOKEN

{
“contact”: {
“organisation_name”: “Acme”,
“country”: “United Kingdom”
}
}

Kind regards,

GraemeOn 23 March 2014 10:04, Tim Ballard tim@tim-ballard.co.uk wrote:

Hello,

We are planning on using the FreeAgent API to allow our customers to check
and update their billing details through our website when signed in.

So far, I have been able to read contact information but I am finding it
impossible to update existing contact information. I seem to be able to
submit an update request without receiving an error but nothing gets
updated.

Here are my request headers, any ideas why this is not working?

PUT /v2/contacts/597884 HTTP/1.1
User-Agent: Lawford Education Ltd
Host: api.freeagent.com
Accept: application/json
Content-type: application/json
Authorization: OAuth MY_TOKEN

{“organisation_name”:“My
Organisation”,“first_name”:“Joe”,“last_name”:“Bloggs”,“email”:"
joe@bloggs.com",“phone_number”:“01234567890”,“address1”:“The
House”,“town”:“Manningtree”,“region”:“Essex”,“postcode”:“AB12CD”,“country”:“United
Kingdom”}

I have tried wrapping the array in a “contact” tag as well but still
nothing. Do I need to include all the input parameters, or just those that
need to be updated?

Many thanks in advance,
Tim


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/d/optout.

Graeme Boyd
Engineering Manager

Web. freeagent.com http://www.freeagent.com/ Blog. freeagent.com/blog
Twitter. @freeagent https://twitter.com/#!/freeagent Facebook.
facebook.com/freeagentapp

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

I just found a possible bug with retrieving contacts unless I am missing
something. When retrieving all contacts, I only seem to get page 1 i.e.
the first 25 contacts. I have more than 25 contacts so how do I retrieve
page 2? Can anyone else verify this?On Monday, 24 March 2014 12:29:45 UTC, Graeme Boyd wrote:

Hi Tim,

You definitely need to wrap the json hash in an outer “contact” hash and
it’s not necessary to specify all parameters - just the ones you want to
change e.g:

PUT /v2/contacts/xxx
User-Agent: useragent
Host: api.freeagent.com
Accept: application/json
Content-type: application/json
Authorization: OAuth MY_TOKEN

{

“contact”: {
“organisation_name”: “Acme”,

"country": "United Kingdom"

}
}

Kind regards,

Graeme

On 23 March 2014 10:04, Tim Ballard <t...@tim-ballard.co.uk <javascript:>>wrote:

Hello,

We are planning on using the FreeAgent API to allow our customers to
check and update their billing details through our website when signed in.

So far, I have been able to read contact information but I am finding it
impossible to update existing contact information. I seem to be able to
submit an update request without receiving an error but nothing gets
updated.

Here are my request headers, any ideas why this is not working?

PUT /v2/contacts/597884 HTTP/1.1
User-Agent: Lawford Education Ltd
Host: api.freeagent.com
Accept: application/json
Content-type: application/json
Authorization: OAuth MY_TOKEN

{“organisation_name”:“My
Organisation”,“first_name”:“Joe”,“last_name”:“Bloggs”,“email”:"
j...@bloggs.com <javascript:>",“phone_number”:“01234567890”,“address1”:“The
House”,“town”:“Manningtree”,“region”:“Essex”,“postcode”:“AB12CD”,“country”:“United
Kingdom”}

I have tried wrapping the array in a “contact” tag as well but still
nothing. Do I need to include all the input parameters, or just those that
need to be updated?

Many thanks in advance,
Tim


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_ap...@googlegroups.com <javascript:>.
To post to this group, send email to freeag...@googlegroups.com<javascript:>
.
Visit this group at http://groups.google.com/group/freeagent_api.
For more options, visit https://groups.google.com/d/optout.


Graeme Boyd
Engineering Manager

Web. freeagent.com http://www.freeagent.com/ Blog. freeagent.com/blog
Twitter. @freeagent https://twitter.com/#!/freeagent Facebook.
facebook.com/freeagentapp

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

Here you go Tim

https://dev.freeagent.com/docs/introduction#paginationOn Monday, March 24, 2014 2:14:52 PM UTC, Tim Ballard wrote:

I just found a possible bug with retrieving contacts unless I am missing
something. When retrieving all contacts, I only seem to get page 1 i.e.
the first 25 contacts. I have more than 25 contacts so how do I retrieve
page 2? Can anyone else verify this?

On Monday, 24 March 2014 12:29:45 UTC, Graeme Boyd wrote:

Hi Tim,

You definitely need to wrap the json hash in an outer “contact” hash and
it’s not necessary to specify all parameters - just the ones you want to
change e.g:

PUT /v2/contacts/xxx
User-Agent: useragent
Host: api.freeagent.com
Accept: application/json
Content-type: application/json
Authorization: OAuth MY_TOKEN

{

“contact”: {
“organisation_name”: “Acme”,

"country": "United Kingdom"

}
}

Kind regards,

Graeme

On 23 March 2014 10:04, Tim Ballard t...@tim-ballard.co.uk wrote:

Hello,

We are planning on using the FreeAgent API to allow our customers to
check and update their billing details through our website when signed in.

So far, I have been able to read contact information but I am finding it
impossible to update existing contact information. I seem to be able to
submit an update request without receiving an error but nothing gets
updated.

Here are my request headers, any ideas why this is not working?

PUT /v2/contacts/597884 HTTP/1.1
User-Agent: Lawford Education Ltd
Host: api.freeagent.com
Accept: application/json
Content-type: application/json
Authorization: OAuth MY_TOKEN

{“organisation_name”:“My
Organisation”,“first_name”:“Joe”,“last_name”:“Bloggs”,“email”:"
j...@bloggs.com",“phone_number”:“01234567890”,“address1”:“The
House”,“town”:“Manningtree”,“region”:“Essex”,“postcode”:“AB12CD”,“country”:“United
Kingdom”}

I have tried wrapping the array in a “contact” tag as well but still
nothing. Do I need to include all the input parameters, or just those that
need to be updated?

Many thanks in advance,
Tim


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_ap...@googlegroups.com.
To post to this group, send email to freeag...@googlegroups.com.
Visit this group at http://groups.google.com/group/freeagent_api.
For more options, visit https://groups.google.com/d/optout.


Graeme Boyd
Engineering Manager

Web. freeagent.com http://www.freeagent.com/ Blog. freeagent.com/blog
Twitter. @freeagent https://twitter.com/#!/freeagent Facebook.
facebook.com/freeagentapp

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

Thanks Olly! I did miss that. All working now.

The code is now deployed in our production environment so customers can use
it to update their billing details on FreeAgent. My next challenge will be
to use the API to remind customers about their open invoices so we have
less chasing to do due to invoices becoming overdue for payment.On Monday, 24 March 2014 14:16:22 UTC, Olly H wrote:

Here you go Tim

https://dev.freeagent.com/docs/introduction#pagination

On Monday, March 24, 2014 2:14:52 PM UTC, Tim Ballard wrote:

I just found a possible bug with retrieving contacts unless I am missing
something. When retrieving all contacts, I only seem to get page 1 i.e.
the first 25 contacts. I have more than 25 contacts so how do I retrieve
page 2? Can anyone else verify this?

On Monday, 24 March 2014 12:29:45 UTC, Graeme Boyd wrote:

Hi Tim,

You definitely need to wrap the json hash in an outer “contact” hash and
it’s not necessary to specify all parameters - just the ones you want to
change e.g:

PUT /v2/contacts/xxx
User-Agent: useragent
Host: api.freeagent.com
Accept: application/json
Content-type: application/json
Authorization: OAuth MY_TOKEN

{

“contact”: {
“organisation_name”: “Acme”,

"country": "United Kingdom"

}
}

Kind regards,

Graeme

On 23 March 2014 10:04, Tim Ballard t...@tim-ballard.co.uk wrote:

Hello,

We are planning on using the FreeAgent API to allow our customers to
check and update their billing details through our website when signed in.

So far, I have been able to read contact information but I am finding
it impossible to update existing contact information. I seem to be able to
submit an update request without receiving an error but nothing gets
updated.

Here are my request headers, any ideas why this is not working?

PUT /v2/contacts/597884 HTTP/1.1
User-Agent: Lawford Education Ltd
Host: api.freeagent.com
Accept: application/json
Content-type: application/json
Authorization: OAuth MY_TOKEN

{“organisation_name”:“My
Organisation”,“first_name”:“Joe”,“last_name”:“Bloggs”,“email”:"
j...@bloggs.com",“phone_number”:“01234567890”,“address1”:“The
House”,“town”:“Manningtree”,“region”:“Essex”,“postcode”:“AB12CD”,“country”:“United
Kingdom”}

I have tried wrapping the array in a “contact” tag as well but still
nothing. Do I need to include all the input parameters, or just those that
need to be updated?

Many thanks in advance,
Tim


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_ap...@googlegroups.com.
To post to this group, send email to freeag...@googlegroups.com.
Visit this group at http://groups.google.com/group/freeagent_api.
For more options, visit https://groups.google.com/d/optout.


Graeme Boyd
Engineering Manager

Web. freeagent.com http://www.freeagent.com/ Blog.
freeagent.com/blog
Twitter. @freeagent https://twitter.com/#!/freeagent Facebook.
facebook.com/freeagentapp

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