ovh / php-ovh

Lightweight PHP wrapper for OVH APIs. That's the easiest way to use OVH.com APIs in your PHP applications.
Other
288 stars 105 forks source link

Impossible to send json through GuzzleHTTP wrapper #137

Closed Kirecom closed 11 months ago

Kirecom commented 11 months ago

Hi,

I'm not an expert dev, but using this wrapper i got some good results, but i'm unable to send json-formatted data to POST methods, for example:

POST /domain/{serviceName}/nameServers/update

asks json formatted data.

So i try to send hostnames as requested:

$result = $ovh->post('/domain/xxxx.xxxx/nameServers/update', array( '' => '{"nameServers":[{"host":"ns1.xxx.xxx"},{"host":"ns2.xxx.xxx"}]}', // Request Body (type: domain.nameServer.UpdatePayload) ));

But i have this error:

Fatal error: Uncaught GuzzleHttp\Exception\ServerException: Server error: POST https://eu.api.ovh.com/1.0/domain/xxxx.xxxx/nameServers/update resulted in a 500 Internal Server Error response: {"class":"Server::InternalServerError","message":"Internal server error"} in

I tried following the official Guzzle guide with no luck...

https://docs.guzzlephp.org/en/latest/request-options.html#json

Is this a bug of the wrapper? Is it fixable, or do you have any hint to workaround this issue with PHP?

I looked around the web but no one seems like trying to update nameservers of their domain with PHP :(

Thank you!

harkor commented 11 months ago

Same issue for me... The call work on API console but didn't on a local php script

Kirecom commented 11 months ago

Glad I'm not the only one having the same issue!

Even the example call is on api.ovh.com under the method fails.... :(

rbeuque74 commented 11 months ago

Hello !

Have you tested using this syntax ?

$result = $ovh->post('/domain/xxxx.xxxx/nameServers/update', array(
   nameServers => array(
      array(
          host => "ns1",
      ),
      array(
          host => "ns2",
      )
   )
));
Kirecom commented 11 months ago

Hello Romain,

I tried this syntax and seems it worked.

$result = $ovh->post('/domain/xxxx.xxxx/nameServers/update', array( "nameServers" => array( array( "host" => "ns1", ), array( "host" => "ns2", ) ) ));

It spawned an operation and DNS update was as i wrote in the array :)))

Thanks!

rbeuque74 commented 11 months ago

Awesome, closing this issue then !

Romain