In karate, multipart is appending some random string to the query while post call which is causing issue in decoding of query at the server end. It looks like some hash code. Problem is explained below, in that "--38699ffae1bd00fc--" is being appended itself while post call. It is creating decoding issue at the server side, which is sending error "json request body could not be decoded: invalid character '-' in numeric literal body:--38699ffae1bd00fc".

For below example:

* multipart field metadata = { operations: '{"query":"\nmutation PicassoUploadImageRpc($endpointRequestData: EndpointRequestData) {\n rpcUploadImage(\n    endpointRequestData: $endpointRequestData\n  ) {\n    message\n   data{\n allImages\n }\n errorDetail{\n errorCode\n errorMessage\n errorType\n displayMessage\n httpStatusCode\n}\n     }\n  }\n","variables":{"endpointRequestData":{"rpcPicasso":{"rpcUploadImage":{"modelType":"modelType1","endPointId":59,"files":[{"key":"image","file":12345}],"body" :{"info":{"hotelCode":"1000115873","hotelId":1000115873,"spaceIds":[],"roomIds":[],"sequence":0,"caption":"hello","description":"hello","tags":["abc"],"sourceConfigName":"ingo","vendorImageId":20,"imgSrc":"makemytrip","isOnBoarding":"true"},"imageUrl":""}}}}}}'}
 
When method POST
Then status 200

Above, " --38699ffae1bd00fc--" is not there in the query anywhere.

while post call(request query shown in report)

... {"operations":"{"query":"\nmutation PicassoUploadImageRpc($endpointRequestData: EndpointRequestData) {\n rpcUploadImage(\n endpointRequestData: $endpointRequestData\n ) {\n message\n data{\n allImages\n }\n errorDetail{\n errorCode\n errorMessage\n errorType\n displayMessage\n httpStatusCode\n}\n }\n }\n","variables":{"endpointRequestData":{"rpcPicasso":{"rpcUploadImage":{"modelType":"modelType1","endPointId":59,"files":[{"key":"image","file":12345}],"body" :{"info":{"hotelCode":"1000115873","hotelId":1000115873,"spaceIds":[],"roomIds":[],"sequence":0,"caption":"hello","description":"hello","tags":["abc"],"sourceConfigName":"ingo","vendorImageId":20,"imgSrc":"makemytrip","isOnBoarding":"true"},"imageUrl":""}}}}}}"} --38699ffae1bd00fc--

Response recieved by post call

{"errors":[{"message":"json request body could not be decoded: invalid character '-' in numeric literal body:--38699ffae1bd00fc\r\ncontent-disposition: form-data; name="metadata"\r\ncontent-length: 810\r\ncontent-type: application/json; charset=UTF-8\r\n\r\n{"operations":"{\"query\":\"\nmutation PicassoUploadImageRpc($endpointRequestData: EndpointRequestData) {\n rpcUploadImage(\n endpointRequestData: $endpointRequestData\n ) {\n message\n data{\n allImages\n }\n errorDetail{\n errorCode\n errorMessage\n errorType\n displayMessage\n httpStatusCode\n}\n }\n }\n\",\"variables\":{\"endpointRequestData\":{\"rpcPicasso\":{\"rpcUploadImage\":{\"modelType\":\"modelType1\",\"endPointId\":59,\"files\":[{\"key\":\"image\",\"file\":12345}],\"body\" :{\"info\":{\"hotelCode\":\"1000115873\",\"hotelId\":1000115873,\"spaceIds\":[],\"roomIds\":[],\"sequence\":0,\"caption\":\"hello\",\"description\":\"hello\",\"tags\":[\"abc\"],\"sourceConfigName\":\"ingo\",\"vendorImageId\":20,\"imgSrc\":\"makemytrip\",\"isOnBoarding\":\"true\"},\"imageUrl\":\"\"}}}}}}"}\r\n--38699ffae1bd00fc--\r\n"}],"data":null}

0

There are 0 best solutions below