I created a simple mock with 2 examples I want to cycle through. To mimic a real world scenario, I’m using the “Authorization”:“Bearer 10x” as the way to choose which Example response I want to get (where x is 1 or 2). I used the x-mock-match-request-headers and put the key “Authorization” in the header of the request. The Examples I saved both have a header “Auhtorization”:“Basic 101” or “Basic 102” for each. When I send the request (with out the x-mock-match-request-headers), I only get the second example. When I enable that header key, I get 404 Not Found
{
“error”: {
“name”: “mockRequestNotFoundError”,
“header”: “No matching requests”,
“message”: “Double check your method and the request path and try again.”
}
}
What am I doing wrong?
Hi rirribarren,
I noticed that you said you were using “Authorization”:“Bearer 10x” where X is 1 or 2 in the second sentence. But then changed that to “Auhtorization”:“Basic 101 later. The difference in Bearer and Basic. Just want to rule that out before we investigate.
John
Sorry…I didn’t mean to get tricky…it’s actually a typo Both Bearer and both “Authorization”. good catch.
I had the same issue and it seems x-mock-match-request-headers works only in lowercase.
So your header can have capital case but when you put that in x-mock-match-request-headers, you have to put it with all small case i.e. “auhtorization” in your case.
Hope this helps.
Thank you Kalpeshone2n. Nice find. I gave up on this and have been using x-mock-response-name and that works pretty well to choose any of the saved script examples by the sample name.