我有 RAML 并发布到 Exchange。单击 API Notebook 以创建 API 文档。内容类型为 application/json
随机存取存储器:
/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 中创建:
```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 错误。有人可以帮我吗???TIA