karate - 如何在空手道中传递 x-www-form-urlencoded - grant_type=client_credentials
问题描述
如何在空手道中传递 x-www-form-urlencoded - grant_type=client_credentials。
你好,
我正在尝试以空手道 x-www-form-urlencoded 的形式传递值 grant_type=client_credentials,这是我与邮递员一起做的。
我知道空手道会将内容类型默认设置为 x-www-form-urlencoded,但是你能帮我在这里做错什么吗?
空手道脚本:
enter code here
Given url 'http://env/singlesignon/v1/access/token'
And header Authorization = 'Basic c2JsLWFwaWdlZS1lemJvYi1jbGllbnQ6c2JsLWFwaWdlZGllbnQ='
And header X-Correlation-Id = 'alibgefh'
And header X-Consumer = 'APIGEE'
And form field grant_type = 'client_credentials'
When method post
Then status 200
请求标头:
enter code here
Authorization: Basic c2JsLWFwaWdlZS1lemJvYi1jbGllbnQ6c2JsLWFwaWdlZGllbnQ=
Connection: Keep-Alive
Content-Length: 29
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Consumer: APIGEE
X-Correlation-Id: alibgefh
回复:
{"error_description":"错误的内容类型","error":"错误的请求"}
解决方案
也许您的服务器不喜欢该charset=UTF-8
部件(这是您服务器上的一个错误)。尝试在之前添加此行:
* configure charset = null
否则您的问题中没有足够的数据。如果可能,请与您的服务器端团队中的某个人合作。您可以尝试使用有效的 cURL 命令编辑您的问题,这可能会有所帮助。
推荐阅读
- bash - SMS 触发的 Bash 文件不会同时触发 GPIO
- json - 与另一个组件共享 JSON 数据
- c++ - 为了在 CUDA 内核中使用 math.h 函数,我无法理解 CUDA 文档
- string - 如果在tensorflow中该行为空,则跳过文本行
- reactjs - 如何获取和显示 API 内容 Onsubmit
- graph-databases - 从随机种子节点遍历图数据库
- java - 冒泡排序的最佳情况是 O(n) 而不是 O(n^2) 的解释?
- java - 从 ml 模型的结果表中的预测列中检索类别名称
- regex - 如何使用正则表达式匹配一行字符串中的多个元素
- css - CSS背景混合模式在带有视口元标记的chrome移动设备中不起作用