我没有得到适当的响应在API笔记本在任何点平台交换

2022-01-30 15:11:18 标签 anypoint-platform

我有RAML并发布到Exchange。点击API笔记本创建API文档。

内容类型是application / json

RAML:

/orders:
  displayName: Orders
  post:
    description: Places a new T-Shirt order
    responses:
      200:
        body:
          application/json:
            example: |
              {
                "size": "M",
                "email": "max@mail.com",
                "name": "Max Malone",
                "address1": "77 Geary St.",
                "address2": "Apt 7",
                "city": "San Francisco",
                "stateOrProvince": "CA",
                "country": "US",
                "postalCode": "94131"
              }
      400:
        body:
          application/json:
            example: |
              {
                "errorMessage": "Bad Request"
              }

创建在API笔记本:

```notebook
API.createClient('Newclient', '1a8f9dfc-4919-4170-8b98-7295f40a3e63', 't-shirt-ordering-service', '1.0.0');
```
Get list of products

笔记本:

Newclient.orders.post({
                "size": "M",
                "email": "max@mail.com",
                "name": "Max Malone",
                "address1": "77 Geary St.",
                "address2": "Apt 7",
                "city": "San Francisco",
                "stateOrProvince": "CA",
                "country": "US",
                "postalCode": "94131"
              });

回应:

API.createClient('Newclient', '1a8f9dfc-4919-4170-8b98-7295f40a3e63', 't-shirt-ordering-service', '1.0.0');
$0=Client has been successfully created
Newclient.orders.post({
                "size": "M",
                "email": "max@mail.com",
                "name": "Max Malone",
                "address1": "77 Geary St.",
                "address2": "Apt 7",
                "city": "San Francisco",
                "stateOrProvince": "CA",
                "country": "US",
                "postalCode": "94131"
              });
$1={
  "body": "Could not resolve host",
  "status": 400",
  "headers": {
    "access-control-allow-origin": "https://anypoint.mulesoft.com",
    "connection": "keep-alive",
    "content-language": "en-gb",
    "content-length": "1876",
    "content-security-policy": "default-src 'none'",
    "content-type": "text/plain",
    "date": "Sun, 19 Sep 2021 13:19:01 GMT",
    "server": "nginx",
    "strict-transport-security": "max-age=31536000; includeSubDomains",
    "vary": "Accept-Language",
    "x-powered-by": "Express",
    "x-xss-protection": "1; mode=block"
  }
}

我希望从这个JavaScript命令得到适当的输出。也尝试了GET方法。得到相同的输出。响应中的“body”被视为糟糕的请求,状态为“400”。我在post方法中提供了所有正确的值,但得到400错误。有人能帮我一下吗?

蒂雅

阅读全文

▼ 版权说明

相关文章也很精彩
推荐内容
更多标签
相关热门
全站排行
随便看看

错说 cuoshuo.com —— 程序员的报错记录

部分内容根据CC版权协议转载;网站内容仅供参考,生产环境使用务必查阅官方文档

辽ICP备19011660号-5

×

扫码关注公众号:职场神器
发送: 1
获取永久解锁本站全部文章的验证码