-1
I have a simple graphql which works well in the maven build but getting error when executed  as a feature file with the standalone karate jar.

Here is the graphql used in request

getCustomerById.graphqls
-----------------------
query{
    getCustomerById(custid:  "12345"){
    custid
    firstname
    lastname
    address1_text
    address2_text
    city_text
    state_text
    zip_text
}
}
-------------------------

#Feature file graphql.feature

* configure ssl = { keyStore: 'classpath:customer/test.pfx', keyStorePassword: 'test123', keyStoreType: 'pkcs12' }
Given url 'https://<IT_URL>/graphql-data/v1/graphql'
* def customerRequest = read('getCustomerById.graphqls')
And def variables = { customerid: '123456'}
And request { query: '#(query)', variables: '#(variables)' }
When method post
Then status 200

* print 'Response ==>', response

getting the following error
======
18:31:42.699 [main]  WARN  com.intuit.karate.JsonUtils - object to json serialization failure, trying alternate approach: [B cannot be cast to [Ljava.lang.Object;
18:31:42.701 [main]  DEBUG com.intuit.karate - request:
2 > POST https://<ITURL>/graphql-data/v1/graphql
2 > Content-Type: application/json; charset=UTF-8
2 > Content-Length: 62
2 > Host: it-xxx-dns.com
2 > Connection: Keep-Alive
2 > User-Agent: Apache-HttpClient/4.5.13 (Java/1.8.0_291)
2 > Accept-Encoding: gzip,deflate
{"variables":{"customerId":"792798178595168"},"query":"[B@7ca8d498"}

18:31:43.060 [main]  DEBUG com.intuit.karate - response time in milliseconds: 357
2 < 200
2 < Date: Wed, 30 Jun 2021 23:31:42 GMT
2 < Content-Type: application/json;charset=UTF-8
2 < Content-Length: 109
2 < Connection: keep-alive
2 < Access-Control-Allow-Origin: *
2 < Access-Control-Allow-Methods: *
2 < Access-Control-Max-Age: 3600
2 < Access-Control-Allow-Headers: authorization, content-type, xsrf-token
2 < Access-Control-Expose-Headers: xsrf-token
2 < Vary: Origin
2 < Vary: Access-Control-Request-Method
2 < Vary: Access-Control-Request-Headers
2 < Strict-Transport-Security: max-age=15724800; includeSubDomains
2 < Set-Cookie: INGRESSCOOKIE=1625095903.954.332.448531; Domain=it-i3-xxx-dns.com; Secure
{"errors":[{"description":"Invalid Syntax : offending token '[' at line 1 column 1","error_code":"400-900"}]}
18:31:43.061 [main]  INFO  com.intuit.karate - [print] Response ==> {
  "errors": [
    {
      "description": "Invalid Syntax : offending token '[' at line 1 column 1",
      "error_code": "400-900"
    }
  ]
}

======

Can you please let me know what's wrong with the code. Is it because of the SSL and passing the pfx file it behaves differently in the standalone jar . I'm not able to find out but it works perfectly fine in the maven build

1 Answers1

0

Yes in stand-alone mode it is preferred you use file: instead of classpath: unless you know how to properly set the class-path.

Please read this for more info and try to figure this out: https://stackoverflow.com/a/58398958/143475

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • changed to file: mode but still getting the same error. The file path is okay (i didnt get filenotfound exception).* configure ssl = { keyStore: 'file:src/features/email/test.pfx', keyStorePassword: 'test123', keyStoreType: 'pkcs12' } – Kumara Subramanian Jul 01 '21 at 17:55
  • @KumaraSubramanian I give up. contribute code (recommended) or follow this process: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue – Peter Thomas Jul 01 '21 at 18:18
  • It worked when i replace reading graphql from a file to give the query as 'text query' as in the graphql.feature. I'm not sure what was the issue with reading graphql as a file and setting a request. One more issue is that i've hardcoded the value for customer id. I tried to give it as a variable inside "" but when printed the query i didn't get the value but "". how to pass a variable inside the text query? . – Kumara Subramanian Jul 01 '21 at 19:35
  • i got it. it worked with replace... saw your answer to another similar question – Kumara Subramanian Jul 01 '21 at 19:57