当前位置: 首页 > 知识库问答 >
问题:

响应是jpg文件-如何用空手道写请求?[副本]

董弘新
2023-03-14

我需要关于适当的空手道请求的指示,以得到响应,这是一个设计的jpg文件

我想我写了有效的请求,因为邮递员能够响应和返回的jpg文件预期。但同样的要求在空手道中不起作用。它返回一些java异常,这些异常没有为我澄清原因。
请帮助!

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)

共有1个答案

厍建义
2023-03-14

我在标题中添加了“accept:*/*”。它解决了问题

 类似资料:
  • 我正在发出一个Soap请求,并接收作为数组返回的响应: 给定SOAPURL 和方法日志 def responseArray=/XML所需代码的路径/ def result=call read(“OtherRequest.Feature”)responseArray 另一个request.feature文件如下所示: 然而,我得到了这个错误: getNewMessageList.feature:27

  • 我用空手道0.9。5.我正在测试一个返回125MB json响应的endpoint(我知道,不应该在json上这样做——但我现在还停留在这里)。我怎样才能禁止空手道解析响应json,而只是将其视为纯文本?响应需要几毫秒才能完成,但空手道只是挂起尝试解析响应。我不需要验证响应,只需检查200 OK。 谢谢

  • 我一直在验证下面的回答。 当我使用空手道发出获取请求时,我会得到以下响应,我想验证它。 我试过: 它说它不是字符串。你能帮我确认一下这个请求吗?

  • 最近我第一次开始与空手道和Yaml合作。我能够验证所有答案数据都在同一水平上的简单回答结构。但现在我不得不验证一个更复杂的结构,我花了很多时间都没有成功。 当我执行GET请求时,我会收到下一个答案: 空手道规则中没有直接的结构验证。它位于如下所示的yml文件中: 我检查了结构大约100次,当我到达这里时,我一直有相同的错误: 错误是下一个:$[1]。工厂|数据类型不匹配(列表:映射) 我尝试使用m

  • 我试图验证非json格式的错误响应体。我尝试了使用模式以及使用包含匹配的关键字。这对我不起作用。 在post调用中观察到多个匹配时从API返回的实际响应: 我的空手道特点: 尝试*匹配实际的[0] == '#(^partSchema)'也从https://gist.github.com/ptrthomas/2a1e30bcb4d782279019b3d5c10b3ed1。不工作

  • 下面是我在点击特定Web服务时收到的JSON响应: 我不知道哪个索引有我的期望值(我需要在确定哪个具有)后验证多个值),这是动态的。不希望使用硬编码值。并匹配,因为这将在下次更改。 对此我有两个问题: 如何将响应传递给java代码并获取具有的数组索引,以便使用此索引进行验证? 下面的代码不起作用。