Bonjour,
J'essaye de faire une requête POST sur un service REST avec php.
En utilisant cURL, l'operation a déroulé correctement:
curl_setopt($ch, CURLOPT_HTTPHEADER,array('Category: network;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";,virtualnetwork; scheme="http://schemas.opennebula.org/occi/infrastructure#";class="mixin";', 'X-OCCI-Attribute: occi.core.title="TEST Network 3",occi.core.summary="A netw summary", opennebula.network.size=256, opennebula.network.address="10.0.0.0",opennebula.network.bridge=virbr0,opennebula.network.public=YES,opennebula.network.type=RANGED'));
Maintenant, je veux exécuter la même commande en utilisant pecl_http, notamment l'objet httprequest :
1 2 3 4 5 6
| $httpRequest->setMethod(constant("HTTP_METH_POST"));
$arg= array('Category: network;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";,virtualnetwork; scheme="http://schemas.opennebula.org/occi/infrastructure#";class="mixin";',
'X-OCCI-Attribute: occi.core.title="My Net222",occi.core.summary="A netwy", opennebula.network.size=256, opennebula.network.address="172.0.0.0",opennebula.network.bridge=virbr0,opennebula.network.public=YES,opennebula.network.type=RANGED');
$httpRequest->addHeaders($arg); |
Ceci n'a pas marché et j'obtiens toujours l'erreur 400.
Partager