1

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)
AlexP
  • 21
  • 2

2 Answers2

1

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

AlexP
  • 21
  • 2
0

I suggest you work with a developer to analyse the request (use the logs or the HTML report) and see if you are missing any header or URL parameter. Also try removing the Then status 200 line.

There is an example of downloading a JPG in the Karate demos here: upload-image.feature

Given path 'files', id
When method get
Then status 200
And match response == read('karate-logo.jpg')

If you are still stuck, please follow this process: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248