Search code examples
curlpodio

Podio create item with Procfu returns error


I need to create an item in Podio using procfu, like this:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://procfu.com/exe/podio_item_create.pf");
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Authorization: Basic MjI4M***********************"] );
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, HTTP_BUILD_QUERY(["app_id"=>"212*****","fields" => ["title"=>'tst']]));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
curl_close ($ch);
print_r ($result);

but the script returns error:

ERROR: PodioBadRequestError: "Invalid value null (null): must be non null"


Solution

  • This is the solution , if anyone needs it :

    curl_setopt($ch, CURLOPT_POSTFIELDS, HTTP_BUILD_QUERY(["app_id"=>"********","fields" => json_encode(["title"=>'tst'])]));
    

    I don't understand why the question was downvoted, it is a very relevant question.