I wonder if this line is working:
'csrf-token' => csrf_token(),
Try setting in header.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Can someone help me with this? I've researched this and tried a lot of examples on SO and other sites, still no success. What it's supposed to do is create an organization (client org) on the simpli.fi ad publishing server.
Today, I decided to test with Postman and got it to work. When using Guzzle, I get various errors but this is the one it lands on the most:
curl_setopt_array(): cannot represent a stream of type Output as a STDIO FILE*
Creating the Client:
$client = new Client([
'debug' => true,
'base_uri' => self::$baseUrl,
'headers' => [
'csrf-token' => csrf_token(),
'x-app-key' => self::$appKey,
'x-user-key' => self::$userKey,
'Content-Type' => 'application/json',
'Accept' => 'application/json',
]
]);
JSON data:
$data = json_encode([
'organization' => [
'name' => "Pete's Pet Pagoda",
'parent_id' => self::$parentId,
]
]);
Create the POST Request
$endpoint = '/organizations';
$response = $client->request('POST', $endpoint, [
'timeout' => 30,
'json' => $data,
]);
Check this, they discuss in detail: https://github.com/guzzle/guzzle/issues/1413
Please or to participate in this conversation.