本文介绍了响应是jpg文件-如何在KARATE中写入请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要有关正确的空手道请求的说明以获取响应,这是设计使然的jpg文件.

我想我写了有效的请求,因为POSTMAN能够响应并按预期返回jpg文件.但是KARATE中的相同请求不起作用.它返回一些Java异常,这些异常并不能说明我的原因.请帮助!

场景
给定url baseUrl
以及路径'api/projects',project_id,'areas',area_id,'issues',issue_id,'attachments',attachment_id
和标题headers
当方法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 ,响应:

I need instruction on proper karate request to get response, which is a jpg file by design .

I suppose I wrote valid request since POSTMAN is able to response and returns jpg file as expected. But the same request in KARATE does not work. It returns some java exception, which do not clarify a reason for me.
Please, help!

SCENARIO
Given url baseUrl
And path 'api/projects', project_id, 'areas', area_id, 'issues', issue_id, 'attachments', attachment_id
And headers headers
When method get
Then status 200

ERROR
java.lang.AssertionError: failed features:fieldManagement.Issues.Attachments.issue-attachments: issue-attachments.feature:190 - status code was: 406, expected: 200, response time: 1338, url: https://qa107.aconex.com/field-management/api/projects/1879048400/areas/271341877549072406/issues/165d00d2-0c04-4cdd-8fc7-1b45443be894/attachments/271341877549091363, response:

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)

推荐答案

我在标题中添加了接受:*/*".它解决了问题

I've added "Accept: */*" to headers. It fixes theproblem

这篇关于响应是jpg文件-如何在KARATE中写入请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-24 18:34