Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V 1.3.1 - json data in Multipart/form-data in Multipart field or Multipart file is not working as a expected #2345

Closed
nkulkarni8 opened this issue Jun 23, 2023 · 2 comments
Labels

Comments

@nkulkarni8
Copy link

nkulkarni8 commented Jun 23, 2023

Hi
I am using Karate version 1.3.1 for our projects. Currently we have a use case to test an API which is taking a file and a metadata as part of the request.

we are using multipart file and field to write our feature file, but it seems when we check the POsT call on report we don’t see the metadata which is a Json going as part of the request.

As per the suggestion in link: #1710

we tried the other approach to use multipart file and value as a parameter but it did not work for us.

Is there any other way to implement this on karate?

note: postman is working without any issues and we get a response too

please help if anyone has faced or resolved this.

Below is my feature file:

  • def temp = { 'upload': ['name':'test', 'org':123, 'branch': 'xyz', 'amount': 100], 'info': 8900, 'id': 123}
    Given url "http://11.111.1.111:1111"
    And path "/api/v1/upload
  • header Content-Type = 'multipart/form-data'
  • multipart file file = {read: 'classpath:resources/file/file1.txt', filename: 'file1.txt'}
  • multipart file metadata = {value: '#(temp)}
    And method POST
  • print response

Note: I also tried * multipart field metadata = temp (but no luck here)

Response:

content-disposition: form-data; name= file; filename="file1.txt"
content-type: text/plain; charset= UTF-8
content-length: 5300
Completed: true
IsInMemory: true

content-disposition: form-data; name= metadata; filename=""
content-type: application/json; charset= UTF-8
content-length: 100
Completed: true
IsInMemory: true

@nkulkarni8
Copy link
Author

The issue is when I run the feature file on Karate the api returns me 200 with a blank response.
Response: { }

but when the same is executed from Postman it returns me response
Response from postman: {id:123, status: ‘Done’}

also I tried the same request with Java okhttpClient request and it worked fine and gave me the expected response.

Is there anything which I am missing while running from Karate?

@ptrthomas
Copy link
Member

closing as unable to replicate and there is a thread for this on stack overflow: https://stackoverflow.com/q/76546469/143475

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants