Powerapps 难以在 collection 中访问 JSON
Powerapps difficulty accessing JSON in collection
我无法通过 PowerApps 访问 collection 中的数据。
我用这个创建 collection:
Collect(coll15,mt.GetAnswers("3b....da","application/json",{question:"eco"}))
使用开发人员工具 -> 网络选项卡 -> 响应正文 - 返回以下 JSON 数据:
{
"answers": [
{
"answer": "This is the answer",
"questions": [
"Private vehicle eco renewal"
],
"score": 82.901087775826454
}
]
}
已创建 collection。
然后我将画廊控件添加到我的页面 - 但是我必须绑定到标签的唯一选项是:ThisItem.Value
如果我尝试输入 ThisItem.Value.answer,我会收到错误消息:“.”的使用无效
如果我输入 ThisItem.answers.answer,我会收到错误消息:名称无效
这是 swagger 文件:
{
"swagger": "2.0",
"info": {
"version": "1.0.0",
"title": "mt",
"description": "mt"
},
"host": "westus.api.cognitive.microsoft.com:443",
"basePath": "/",
"schemes": [
"https"
],
"consumes": [],
"produces": [
"application/json"
],
"paths": {
"/qnamaker/v2.0/knowledgebases/eeeee.....eeeee/generateAnswer": {
"post": {
"summary": "GetAnswers",
"description": "Get answers from qna",
"operationId": "GetAnswers",
"parameters": [
{
"name": "body",
"in": "body",
"schema": {
"type": "object",
"properties": {
"question": {
"type": "string",
"description": "question",
"x-ms-summary": "question",
"title": "question",
"x-ms-visibility": ""
}
},
"default": {
"question": "hi"
},
"required": [
"question"
]
},
"required": true
}
],
"responses": {
"default": {
"description": "default",
"schema": {
"type": "string"
}
}
}
}
}
},
"definitions": {},
"parameters": {},
"responses": {},
"securityDefinitions": {
"api_key": {
"type": "apiKey",
"in": "header",
"name": "Ocp-Apim-Subscription-Key"
}
},
"security": [
{
"oauth2_auth": [
"Offline-Access"
]
}
],
"tags": []
}
我有什么方法可以访问 collection 中的答案文本吗?
感谢您的帮助,
马克
问题是连接器定义中操作的响应类型是字符串:
"responses": {
"default": {
"description": "default",
"schema": {
"type": "string"
}
}
}
但你的回应是一个对象。如果您将自定义连接器更新为使用类型化对象,您应该能够访问操作的响应。符合以下架构的内容:
"responses": {
"default": {
"description": "default",
"schema": {
"type": "object",
"properties": {
"answers": {
"type": "array",
"items": {
"type": "object",
"properties": {
"answer": {
"type": "string"
},
"questions": {
"type": "array",
"items": {
"type": "string"
}
},
"score": {
"type": "number",
"format": "float"
}
}
}
}
}
}
}
},
请注意,在门户 (web.powerapps.com) 中,如果您转到自定义连接器定义,并且 select "Edit",您可以转到操作,并且 select 您要编辑的回复:
然后使用"Import from sample"选项
这样,如果您输入来自 API 的响应示例,它将为您创建模式(与我上面的模式类似)。
我无法通过 PowerApps 访问 collection 中的数据。
我用这个创建 collection:
Collect(coll15,mt.GetAnswers("3b....da","application/json",{question:"eco"}))
使用开发人员工具 -> 网络选项卡 -> 响应正文 - 返回以下 JSON 数据:
{
"answers": [
{
"answer": "This is the answer",
"questions": [
"Private vehicle eco renewal"
],
"score": 82.901087775826454
}
]
}
已创建 collection。
然后我将画廊控件添加到我的页面 - 但是我必须绑定到标签的唯一选项是:ThisItem.Value
如果我尝试输入 ThisItem.Value.answer,我会收到错误消息:“.”的使用无效
如果我输入 ThisItem.answers.answer,我会收到错误消息:名称无效
这是 swagger 文件:
{
"swagger": "2.0",
"info": {
"version": "1.0.0",
"title": "mt",
"description": "mt"
},
"host": "westus.api.cognitive.microsoft.com:443",
"basePath": "/",
"schemes": [
"https"
],
"consumes": [],
"produces": [
"application/json"
],
"paths": {
"/qnamaker/v2.0/knowledgebases/eeeee.....eeeee/generateAnswer": {
"post": {
"summary": "GetAnswers",
"description": "Get answers from qna",
"operationId": "GetAnswers",
"parameters": [
{
"name": "body",
"in": "body",
"schema": {
"type": "object",
"properties": {
"question": {
"type": "string",
"description": "question",
"x-ms-summary": "question",
"title": "question",
"x-ms-visibility": ""
}
},
"default": {
"question": "hi"
},
"required": [
"question"
]
},
"required": true
}
],
"responses": {
"default": {
"description": "default",
"schema": {
"type": "string"
}
}
}
}
}
},
"definitions": {},
"parameters": {},
"responses": {},
"securityDefinitions": {
"api_key": {
"type": "apiKey",
"in": "header",
"name": "Ocp-Apim-Subscription-Key"
}
},
"security": [
{
"oauth2_auth": [
"Offline-Access"
]
}
],
"tags": []
}
我有什么方法可以访问 collection 中的答案文本吗?
感谢您的帮助,
马克
问题是连接器定义中操作的响应类型是字符串:
"responses": {
"default": {
"description": "default",
"schema": {
"type": "string"
}
}
}
但你的回应是一个对象。如果您将自定义连接器更新为使用类型化对象,您应该能够访问操作的响应。符合以下架构的内容:
"responses": {
"default": {
"description": "default",
"schema": {
"type": "object",
"properties": {
"answers": {
"type": "array",
"items": {
"type": "object",
"properties": {
"answer": {
"type": "string"
},
"questions": {
"type": "array",
"items": {
"type": "string"
}
},
"score": {
"type": "number",
"format": "float"
}
}
}
}
}
}
}
},
请注意,在门户 (web.powerapps.com) 中,如果您转到自定义连接器定义,并且 select "Edit",您可以转到操作,并且 select 您要编辑的回复:
然后使用"Import from sample"选项
这样,如果您输入来自 API 的响应示例,它将为您创建模式(与我上面的模式类似)。