Creating a contact

Hi James,

Your code needs to set an Accept http header with a value
of application/json or application/xml to declare the format in which it
would like responses to be sent. I imagine that should be set where the
user agent is set:

array(‘User-Agent’ => ‘Fantrac’, ‘Accept’ => ‘application/json’)

Kind regards,

GraemeOn 29 April 2013 13:12, james stevenson stevjl2@googlemail.com wrote:

I have set up a sandbox account and enabled the api feed. This is my code,
I’ve just copied the data used in
https://dev.freeagent.com/docs/contacts#create-a-contact

I want to be able to create a contact but getting this error, I have
attached the full script

Array
(
[result] => **
**
**
Format not recognised. Set accept http header to application/json or application/xml
**


[code] => 400
[content_type] => application/xml; charset=utf-8

)

//and make the request to the API
$response = $client->fetch(
    $base_url . '/contact', //API path
    array('contact' =>
    array(

‘first_name’ => “test”,
‘last_name’ => “me”,
‘contact_name_on_invoices’ => “true”,
‘country’ => ‘United Kingdom’,
‘locale’ => “en”,
‘account_balance’ => “-100.0”,
‘uses_contact_invoice_sequenc’ => “false”,
‘created_at’ => “2011-09-14T16:00:41Z”,
‘updated_at’ => “2011-09-16T09:34:41Z”
)
), //request parameters
OAuth2\Client::HTTP_METHOD_GET, //GET, PUT, POST, DELETE
array(‘User-Agent’ => ‘Fantrac’) //API requires UA header
);


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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

Graeme Boyd
Senior Software Engineer

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