我需要有关正确的空手道要求的说明以获取响应,这是设计使然的jpg文件。
我想我写了有效的请求,因为POSTMAN能够响应并按预期返回jpg文件。但是KARATE中的相同请求不起作用。它返回一些Java异常,这些异常无法说明我的原因。
请帮忙!
场景
给定url baseUrl
路径“ api / projects”,project_id,“ areas”,area_id,“ issues”,issue_id,“ attachments”,attachment_id
和标题标题
当方法get
然后状态200
错误
java.lang.AssertionError:失败的功能:
fieldManagement.Issues.Attachments.issue-attachments:issue-attachments.feature:190-状态码为:406,预期:200,响应时间:1338,url:https://qa107.aconex.com/field-management/api/projects/1879048400/areas/271341877549072406/issues/165d00d2-0c04-4cdd-8fc7-1b45443be894/attachments/271341877549091363,响应:
at org.junit.Assert.fail(Assert.java:88)
at org.junit.Assert.assertTrue(Assert.java:41)
at fieldManagement.Issues.Attachments.issueAttachment.testIssueAttachment(issueAttachment.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
答案 0 :(得分:1)
我在标题中添加了“接受:* / *”。它解决了问题
答案 1 :(得分:0)
我建议您与开发人员一起分析请求(使用日志或HTML报告),并查看是否缺少任何标题或URL参数。另外,请尝试删除Then status 200
行。
这里有一个在空手道演示中下载JPG的示例:upload-image.feature
Given path 'files', id
When method get
Then status 200
And match response == read('karate-logo.jpg')
如果您仍然遇到问题,请执行以下过程:https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue