Search code examples
phpapipodio

PodioBadRequestError when creating a item via API [Invoice APP]


I am creating a items into PODIO apps via API, I am able to create an item to 3 apps(Client, lineitem, and claim) but I am not able to create an item on Invoice APP, I am getting "PodioBadRequestError" error each time while I am doing same as I did on other apps.

I am using a PHP library.

Here is a part of the script that I am using:

$newInvoice = array('fields'=>array(
                'date-created' => '2018-07-23',
                'third-party' => '5',
                'due-date' => '2018-07-28'
              ));

Podio::setup($clientID, $clientSECRET);
Podio::authenticate_with_app($invoiceAPPID, $invoiceAPPToken);
Podio::set_debug(true);
$invoice = PodioItem::create($invoiceAPPID, $newInvoice);

Can you please have a look into my request and guide me where I am doing wrong.

Thanks


Solution

  • You are passing the values in the wrong format. If date-created and due-date are Podio Date fields, then you must put the date in 'Y-m-d H:i:s' format and pass it to 'start' key.

    Try this,

    $newInvoice = array('fields'=>array(
                    'date-created' => array('start'=>date('Y-m-d H:i:s', strtotime('2018-07-23'))),
                    'third-party' => 5,
                    'due-date' => array('start'=>date('Y-m-d H:i:s', strtotime('2018-07-28')))
                  ));
    
    //third-party is an integer field