首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ovh 400错误请求响应

ovh 400错误请求响应
EN

Stack Overflow用户
提问于 2021-02-05 17:54:14
回答 2查看 206关注 0票数 1

当我尝试在laravel代码中使用ovh API创建子域时,我得到了这个错误。

代码语言:javascript
复制
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"}

我的PHP代码如下所示:

代码语言:javascript
复制
$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;

谢谢你的帮助。

EN

回答 2

Stack Overflow用户

发布于 2021-02-05 21:52:17

INVALID_SIGNATURE表示缺少某些参数或某些值与请求的参数类型(stringlong等)不匹配。

在您的例子中,参数ttl需要是一个long,但是您给了它一个string

它应该更好地使用:

代码语言:javascript
复制
$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)
));

这里唯一的区别是'0'0 (没有简单的引号)

签名可以在这里找到:

如果您通过此接口控制台执行请求,在Raw选项卡中可以看到生成的请求:

代码语言:javascript
复制
{
  "fieldType": "A",
  "subDomain": "test-sousdomain",
  "target": "monIp",
  "ttl": 0
}
票数 0
EN

Stack Overflow用户

发布于 2021-05-22 22:37:36

代码语言:javascript
复制
    $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:

这应该返回可用字段类型的列表。它的返回值是一个整数。

您正在将'A'作为字符串传递。我建议您将其更改为。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66061092

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档