Search code examples
karatebinaryfiles

Unable to upload binary file with Content-Type: application/x-java-serialized-object in karate


enter image description here binary file content

Karate script we trying to run

    Feature: getSummary
 
Background: Setup
  * def constants  =  read(FEATURES_PATH + 'testfeatures/cc/hmm/common/MdsData.json')
  * callonce read(FEATURES_PATH + 'testfeatures/bb/cc/common/test.feature')
  * configure headers = ({'Content-Type': 'application/x-java-serialized-object','Accept': '*/*','Authorization': authCredentials,'Accept-Encoding': 'gzip,deflate,br','remoteUsername':'[email protected]', 'executeAsRemoteUserFlag':true,Accept:HEADER_ACCEPT, Connection:HEADER_CONNECTION})
 
Scenario:  Binary content    
    Given url BASE_URL + '/txt/remote/Service/getSummary'
    And request read('test.txt')
    When method POST
    Then status 200 

Solution

  • The only suggestion I have is try this - since you are working with binary. Which cannot be treated as plain text.

    And request karate.readAsBytes('test.txt')