I am adding new bill by HTTP_METHOD_POST Freeagent APi and posting data but I am not getting any response in result

Below is code.

$adata=Array(

‘url’=>‘https://api.sandbox.freeagent.com/v2/bills/1169’,
‘contact’ =>
https://api.sandbox.freeagent.com/v2/contacts/32955’,
‘category’ =>
https://api.sandbox.freeagent.com/v2/categories/285’,
‘reference’ => ‘biile2’,
‘dated_on’ => ‘2016-04-28’,
‘due_on’=> ‘2016-05-28’,
‘total_value’ => ‘34.0’,
‘paid_value’ => ‘0.0’,
‘due_value’ => ‘74.0’,
‘status’ => ‘Open’,
‘sales_tax_rate’=> ‘7.8’,
‘rebill_type’ => ‘markup’,
‘updated_at’ => ‘016-04-22T14:34:21.000Z’,
‘created_at’ => ‘2016-04-22T14:34:21.000Z’,

                    );
         
         //print_r(json_encode($adata));die;

         //echo $base_url. '/'.$apiName;die;

         
         $response = $client->fetch(
         $base_url . '/'.$apiName, //API path  //contacts  

//categories //bills //invoices
json_encode($adata), //request parameters
OAuth2\Client::HTTP_METHOD_POST, //GET, PUT, POST, DELETE
array(‘User-Agent’ => $userAgentHeader)//API requires UA header

Not getting any response. Please help.

Thanks,
Sunil

Hi Sunil,

Please could you clarify what you’re trying to achieve with the above
request, are you attempting to update an existing bill?
It looks like you might have copied the response from our API
documentation, rather than crafting your own request.

If you’re trying to update the bill with database ID 1169, you need send a
PUT request (not a POST) to the following API endpoint
https://api.sandbox.freeagent.com/v2/bills/1169
The bill itself should not be passed as an argument, you need to remove the
“URL” element from your array.
You also need to remove the created_at and updated_at timestamps as these
can’t be updated by the client (they’re managed by our database).

The following API documentation lists the fields that can be safely passed
to the bills end-point, within the request body.

I hope this helps and if you have any further queries, could I kindly ask
that you provide the following information in your posts.
https://groups.google.com/forum/#!topic/freeagent_api/vAA_bUlVnJU

Thanks,
Dave JOn 28 April 2016 at 15:53, sunil@webequator.com wrote:

Below is code.

$adata=Array(
‘url’=>’
https://api.sandbox.freeagent.com/v2/bills/1169’,
‘contact’ => ’
https://api.sandbox.freeagent.com/v2/contacts/32955’,
‘category’ => ’
https://api.sandbox.freeagent.com/v2/categories/285’,
‘reference’ => ‘biile2’,
‘dated_on’ => ‘2016-04-28’,
‘due_on’=> ‘2016-05-28’,
‘total_value’ => ‘34.0’,
‘paid_value’ => ‘0.0’,
‘due_value’ => ‘74.0’,
‘status’ => ‘Open’,
‘sales_tax_rate’=> ‘7.8’,
‘rebill_type’ => ‘markup’,
‘updated_at’ => ‘016-04-22T14:34:21.000Z’,
‘created_at’ => ‘2016-04-22T14:34:21.000Z’,

                    );

         //print_r(json_encode($adata));die;

         //echo $base_url. '/'.$apiName;die;


         $response = $client->fetch(
         $base_url . '/'.$apiName, //API path  //contacts

//categories //bills //invoices
json_encode($adata), //request parameters
OAuth2\Client::HTTP_METHOD_POST, //GET, PUT, POST, DELETE
array(‘User-Agent’ => $userAgentHeader)//API requires UA
header

Not getting any response. Please help.

Thanks,
Sunil


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 https://groups.google.com/group/freeagent_api.
For more options, visit https://groups.google.com/d/optout.

David Jones
Support Engineering Team Lead

FreeAgent