1

i have this code:

Scenario: Get Token     
Given url 'https://localhost/api/accessToken'     
And param scope = 'collections payments'

Log: 1 > POST https://localhost/api/accessToken?scope=collections+payments

This Post faild for me.

Please, i need this: https://localhost/api/accessToken?scope=collections%20payments

1 Answers1

1

Karate is doing the right thing and your server probably has a bug.

Refer: https://stackoverflow.com/a/1634293/143475

But if you want to send it the way you are asking, put it as the URL itself, and don't use param:

* url 'https://httpbin.org/anything?foo=one%20two'
* method post

Explained here: https://stackoverflow.com/a/59977660/143475

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • thanks Peter, but this example is API POST with Query Params, this works? cause im getting *http call failed* – Jesus Ovalle Apr 12 '23 at 17:18
  • @JesusOvalle I have nothing to add to my answer, as I said - maybe something is seriously wrong with your server. I suggest you work with someone who understands the server-side on your team, or someone who knows how to send the correct request to your server. karate supports get, post and everything, refer the docs. if still stuck - follow this process: https://github.com/karatelabs/karate/wiki/How-to-Submit-an-Issue – Peter Thomas Apr 12 '23 at 17:26
  • A little late to the party, but did you try `And param scope = karate.urlEncode(collections payments)` – mike Aug 26 '23 at 00:57