使用连字符分隔的资源名称 "/songs-list" 创建 API Notebook 时,会出现错误
When creating an API Notebook with a hyphen separated resource name "/songs-list" , it gives an error
在 RAML 1.0、API 平台 2.0 上使用连字符分隔的资源名称“/songs-list”创建 API Notebook 时,会出现以下错误:
APINotebook Error
API.createClient('client', '9c2861a1-b**b-401e-****-1ec*****b20c', 'testhyphen', '1.0.2');
$0=客户端创建成功
client.songs-list.post[{"msg":"succ"}];
=ReferenceError: list is not defined
at eval (eval at <anonymous> (eval at value (https://cdn.anypoint.mulesoft.com/artifacts/exchange-ui/main.efc15523965187f6c807.js:1:998504)), <anonymous>:1:14)
at Object.eval (eval at value (https://cdn.anypoint.mulesoft.com/artifacts/exchange-ui/main.efc15523965187f6c807.js:1:998504), <anonymous>:3:8)
at e.value (https://cdn.anypoint.mulesoft.com/artifacts/exchange-ui/main.efc15523965187f6c807.js:1:998611)
at https://cdn.anypoint.mulesoft.com/artifacts/exchange-ui/main.efc15523965187f6c807.js:1:2212756
at h.run (https://cdn.anypoint.mulesoft.com/artifacts/exchange-ui/main.efc15523965187f6c807.js:1:282445)
at p (https://cdn.anypoint.mulesoft.com/artifacts/exchange-ui/main.efc15523965187f6c807.js:1:281939)
at nrWrapper (https://anypoint.mulesoft.com/exchange/9c2861a1-b**b-401e-****-1ec*****b20c/testhyphen/minor/1.0/:1:24554)
上述资产的 RAML 如下,资源名称为“/songs-list”:
#%RAML 1.0
title: testhyphen
/songs-list:
post:
body:
application/json:
responses:
200:
body:
application/json:
example: {"messgae": "Success"}
如果资源名称不包含“-”(连字符),例如,当资源为 -“/songs”时,API 笔记本将按预期运行。
API Notebook success
API.createClient('client', '9c2861a1-b**b-401e-****-1ec*****b20c', 'testset', '1.0.1');
[=16=]=Client has been successfully created
client.songs.post[{"msg":"succ"}];
Code snippet executed with no results
您可以使用此格式 运行 成功:
clients['songs-list'].post[{"msg":"succ"}];
如果没有这种格式,它会将连字符视为减法运算符。由于 APINotebook 运行s 在 JavaScript 上,并且支持任何 JavaScript 语法,您可以在 JavaScript 中查看如何做事情,它们应该与 APINotebook 一起工作。
在 RAML 1.0、API 平台 2.0 上使用连字符分隔的资源名称“/songs-list”创建 API Notebook 时,会出现以下错误: APINotebook Error
API.createClient('client', '9c2861a1-b**b-401e-****-1ec*****b20c', 'testhyphen', '1.0.2');
$0=客户端创建成功
client.songs-list.post[{"msg":"succ"}];
=ReferenceError: list is not defined
at eval (eval at <anonymous> (eval at value (https://cdn.anypoint.mulesoft.com/artifacts/exchange-ui/main.efc15523965187f6c807.js:1:998504)), <anonymous>:1:14)
at Object.eval (eval at value (https://cdn.anypoint.mulesoft.com/artifacts/exchange-ui/main.efc15523965187f6c807.js:1:998504), <anonymous>:3:8)
at e.value (https://cdn.anypoint.mulesoft.com/artifacts/exchange-ui/main.efc15523965187f6c807.js:1:998611)
at https://cdn.anypoint.mulesoft.com/artifacts/exchange-ui/main.efc15523965187f6c807.js:1:2212756
at h.run (https://cdn.anypoint.mulesoft.com/artifacts/exchange-ui/main.efc15523965187f6c807.js:1:282445)
at p (https://cdn.anypoint.mulesoft.com/artifacts/exchange-ui/main.efc15523965187f6c807.js:1:281939)
at nrWrapper (https://anypoint.mulesoft.com/exchange/9c2861a1-b**b-401e-****-1ec*****b20c/testhyphen/minor/1.0/:1:24554)
上述资产的 RAML 如下,资源名称为“/songs-list”:
#%RAML 1.0
title: testhyphen
/songs-list:
post:
body:
application/json:
responses:
200:
body:
application/json:
example: {"messgae": "Success"}
如果资源名称不包含“-”(连字符),例如,当资源为 -“/songs”时,API 笔记本将按预期运行。 API Notebook success
API.createClient('client', '9c2861a1-b**b-401e-****-1ec*****b20c', 'testset', '1.0.1');
[=16=]=Client has been successfully created
client.songs.post[{"msg":"succ"}];
Code snippet executed with no results
您可以使用此格式 运行 成功:
clients['songs-list'].post[{"msg":"succ"}];
如果没有这种格式,它会将连字符视为减法运算符。由于 APINotebook 运行s 在 JavaScript 上,并且支持任何 JavaScript 语法,您可以在 JavaScript 中查看如何做事情,它们应该与 APINotebook 一起工作。