1

I am getting this error when trying to create subdomain using ovh API in laravel code.

POST https://eu.api.ovh.com/1.0/domain/zone/mondomain.com/record resulted in a 400 Bad Request response: {"message":"Invalid signature","httpCode":"400 Bad Request","errorCode":"INVALID_SIGNATURE"}

My PHP code looks like :

$ovh = new Api(
    $applicationKey, // Application Key
    $applicationSecret, // Application Secret
    'ovh-eu', // Endpoint of API OVH Europe (List of available endpoints)
    $consumerKey
); // Consumer Key

$result = $ovh->post(
    '/domain/zone/mondomain.com/record',
    array(
        'fieldType' => 'A', // Resource record Name (type: zone.NamedResolutionFieldTypeEnum)
        'subDomain' => 'test-sousdomain', // Resource record subdomain (type: string)
        'target' => 'monIP', // Resource record target (type: string) ssh root@
        'ttl' => '0', // Resource record ttl (type: long)
    )
);
return $result;

Thank for your help.

Pierre
  • 2,552
  • 5
  • 26
  • 47

2 Answers2

0

The INVALID_SIGNATURE means some parameters are missing or are some values are not matching the requested parameters type (string, long etc.)

In your case, the parameters ttl needs to be a long, but you gave it a string.

It should be better with:

$result = $ovh->post('/domain/zone/mondomain.com/record', array(
    'fieldType' => 'A', // Resource record Name (type: zone.NamedResolutionFieldTypeEnum)
    'subDomain' => 'test-sousdomain', // Resource record subdomain (type: string)
    'target' => 'monIP', // Resource record target (type: string) ssh root@
    'ttl' => 0, // Resource record ttl (type: long)
));

The only difference here is the '0' vs 0 (without the simple quotes)

The signature can be found here: /domain/zone/{zone_name}/record

If you execute your request through this API console, in the Raw tab you can see the generated request:

{
  "fieldType": "A",
  "subDomain": "test-sousdomain",
  "target": "monIp",
  "ttl": 0
}
Pierre
  • 2,552
  • 5
  • 26
  • 47
0
    $result = $ovh->post('/domain/zone/mondomain.com/record', array(
        'fieldType' => 'A', // Resource record Name (type: zone.NamedResolutionFieldTypeEnum)
        'subDomain' => 'test-sousdomain', // Resource record subdomain (type: string)
        'target' => 'monIP', // Resource record target (type: string) ssh root@
        'ttl' => 0, // Resource record ttl (type: long)
    ));

zone.NamedResolutionFieldTypeEnum:

This should return the list of available Field type. The return of this is an integer.

You are passing 'A' as a string. I suggest you change it to 0.

abed maatalla
  • 31
  • 1
  • 9