How to send authorization code from 1 API to another API using Regular Expression Extractor in Jmeter










0














I have an API name loginUser, which generates the authorization Token, that is to be passed in other subsequent APIs.

Below is the response:-

HTTP/1.1 200 OK Date: Sat, 10 Nov 2018 07:08:45 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 71 Connection:
keep-alive Server: nginx/1.10.3 (Ubuntu)
X-Powered-By: Express Access-Control-Allow-Origin: * Access-Control-Expose-Headers: date, authorization, x-powered-by, connection, server, access-control-allow-origin, content-type, content-length, x-final-url

authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIyYmEyYjc1My03NWEwLTQxNGYtYWFiOC0zZGY1M2I4YmIwMDEiLCJpc0Nvb2siOnRydWUsImlhdCI6MTU0MTgzMzcyNX0.3FRVpHm4EF2Ahzzy-OjbZ2EeZto6-hSFKHNtG5wcjBs

Where I want to fetch the authorization.

I'm using Regular Expression Extractor, but it is throwing below error


org.apache.http.client.ClientProtocolException: URI does not specify a valid host name: http:/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI4MWFiNzI3NS01MWU2LTQyMTctYmJlNC03ZTJlYjk1Y2M1NGYiLCJpc0Nvb2siOnRydWUsImlhdCI6MTU0MTk5NDY0NX0.kI0VrNARu09iG589g80ruqNFkoUQDg2iI9sw2nOuasU
at org.apache.http.impl.client.CloseableHttpClient.determineTarget(CloseableHttpClient.java:95)



 Snapshots:-

[Step_1][1]
[Step_2][2]
[Step_3][3]
[Step_4][4]


[1]: https://i.stack.imgur.com/x2aC8.png
[2]: https://i.stack.imgur.com/plORl.png
[3]: https://i.stack.imgur.com/Xe6aY.png
[4]: https://i.stack.imgur.com/FQMjZ.png


Please let me know, what can be done to solve this issue.
Thanks in advance.










share|improve this question





















  • Hi. Can you please paste the image of the request corresponding to the erroneous HTTP Auth Token sampler?
    – M Navneet Krishna
    Nov 12 at 4:52















0














I have an API name loginUser, which generates the authorization Token, that is to be passed in other subsequent APIs.

Below is the response:-

HTTP/1.1 200 OK Date: Sat, 10 Nov 2018 07:08:45 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 71 Connection:
keep-alive Server: nginx/1.10.3 (Ubuntu)
X-Powered-By: Express Access-Control-Allow-Origin: * Access-Control-Expose-Headers: date, authorization, x-powered-by, connection, server, access-control-allow-origin, content-type, content-length, x-final-url

authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIyYmEyYjc1My03NWEwLTQxNGYtYWFiOC0zZGY1M2I4YmIwMDEiLCJpc0Nvb2siOnRydWUsImlhdCI6MTU0MTgzMzcyNX0.3FRVpHm4EF2Ahzzy-OjbZ2EeZto6-hSFKHNtG5wcjBs

Where I want to fetch the authorization.

I'm using Regular Expression Extractor, but it is throwing below error


org.apache.http.client.ClientProtocolException: URI does not specify a valid host name: http:/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI4MWFiNzI3NS01MWU2LTQyMTctYmJlNC03ZTJlYjk1Y2M1NGYiLCJpc0Nvb2siOnRydWUsImlhdCI6MTU0MTk5NDY0NX0.kI0VrNARu09iG589g80ruqNFkoUQDg2iI9sw2nOuasU
at org.apache.http.impl.client.CloseableHttpClient.determineTarget(CloseableHttpClient.java:95)



 Snapshots:-

[Step_1][1]
[Step_2][2]
[Step_3][3]
[Step_4][4]


[1]: https://i.stack.imgur.com/x2aC8.png
[2]: https://i.stack.imgur.com/plORl.png
[3]: https://i.stack.imgur.com/Xe6aY.png
[4]: https://i.stack.imgur.com/FQMjZ.png


Please let me know, what can be done to solve this issue.
Thanks in advance.










share|improve this question





















  • Hi. Can you please paste the image of the request corresponding to the erroneous HTTP Auth Token sampler?
    – M Navneet Krishna
    Nov 12 at 4:52













0












0








0







I have an API name loginUser, which generates the authorization Token, that is to be passed in other subsequent APIs.

Below is the response:-

HTTP/1.1 200 OK Date: Sat, 10 Nov 2018 07:08:45 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 71 Connection:
keep-alive Server: nginx/1.10.3 (Ubuntu)
X-Powered-By: Express Access-Control-Allow-Origin: * Access-Control-Expose-Headers: date, authorization, x-powered-by, connection, server, access-control-allow-origin, content-type, content-length, x-final-url

authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIyYmEyYjc1My03NWEwLTQxNGYtYWFiOC0zZGY1M2I4YmIwMDEiLCJpc0Nvb2siOnRydWUsImlhdCI6MTU0MTgzMzcyNX0.3FRVpHm4EF2Ahzzy-OjbZ2EeZto6-hSFKHNtG5wcjBs

Where I want to fetch the authorization.

I'm using Regular Expression Extractor, but it is throwing below error


org.apache.http.client.ClientProtocolException: URI does not specify a valid host name: http:/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI4MWFiNzI3NS01MWU2LTQyMTctYmJlNC03ZTJlYjk1Y2M1NGYiLCJpc0Nvb2siOnRydWUsImlhdCI6MTU0MTk5NDY0NX0.kI0VrNARu09iG589g80ruqNFkoUQDg2iI9sw2nOuasU
at org.apache.http.impl.client.CloseableHttpClient.determineTarget(CloseableHttpClient.java:95)



 Snapshots:-

[Step_1][1]
[Step_2][2]
[Step_3][3]
[Step_4][4]


[1]: https://i.stack.imgur.com/x2aC8.png
[2]: https://i.stack.imgur.com/plORl.png
[3]: https://i.stack.imgur.com/Xe6aY.png
[4]: https://i.stack.imgur.com/FQMjZ.png


Please let me know, what can be done to solve this issue.
Thanks in advance.










share|improve this question













I have an API name loginUser, which generates the authorization Token, that is to be passed in other subsequent APIs.

Below is the response:-

HTTP/1.1 200 OK Date: Sat, 10 Nov 2018 07:08:45 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 71 Connection:
keep-alive Server: nginx/1.10.3 (Ubuntu)
X-Powered-By: Express Access-Control-Allow-Origin: * Access-Control-Expose-Headers: date, authorization, x-powered-by, connection, server, access-control-allow-origin, content-type, content-length, x-final-url

authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIyYmEyYjc1My03NWEwLTQxNGYtYWFiOC0zZGY1M2I4YmIwMDEiLCJpc0Nvb2siOnRydWUsImlhdCI6MTU0MTgzMzcyNX0.3FRVpHm4EF2Ahzzy-OjbZ2EeZto6-hSFKHNtG5wcjBs

Where I want to fetch the authorization.

I'm using Regular Expression Extractor, but it is throwing below error


org.apache.http.client.ClientProtocolException: URI does not specify a valid host name: http:/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI4MWFiNzI3NS01MWU2LTQyMTctYmJlNC03ZTJlYjk1Y2M1NGYiLCJpc0Nvb2siOnRydWUsImlhdCI6MTU0MTk5NDY0NX0.kI0VrNARu09iG589g80ruqNFkoUQDg2iI9sw2nOuasU
at org.apache.http.impl.client.CloseableHttpClient.determineTarget(CloseableHttpClient.java:95)



 Snapshots:-

[Step_1][1]
[Step_2][2]
[Step_3][3]
[Step_4][4]


[1]: https://i.stack.imgur.com/x2aC8.png
[2]: https://i.stack.imgur.com/plORl.png
[3]: https://i.stack.imgur.com/Xe6aY.png
[4]: https://i.stack.imgur.com/FQMjZ.png


Please let me know, what can be done to solve this issue.
Thanks in advance.







regex jmeter authorization extractor






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 12 at 4:18









shank

83




83











  • Hi. Can you please paste the image of the request corresponding to the erroneous HTTP Auth Token sampler?
    – M Navneet Krishna
    Nov 12 at 4:52
















  • Hi. Can you please paste the image of the request corresponding to the erroneous HTTP Auth Token sampler?
    – M Navneet Krishna
    Nov 12 at 4:52















Hi. Can you please paste the image of the request corresponding to the erroneous HTTP Auth Token sampler?
– M Navneet Krishna
Nov 12 at 4:52




Hi. Can you please paste the image of the request corresponding to the erroneous HTTP Auth Token sampler?
– M Navneet Krishna
Nov 12 at 4:52












1 Answer
1






active

oldest

votes


















0














The error you're getting is not related to the Regular Expression Extractor at all, it is about some HTTP Request sampler having incorrect hostname



As far as I can see you can successfully extract the header value, but you should not be using it as the hostname, most probably it should go:



  • as one of the request parameters (i.e. directly in body or as a part of the URL)

  • as a HTTP Cookie

  • as a HTTP Header

So you need to find out how the token should be passed and provide the variable from the regular expression extractor there, but it is obviously not "Server Name or IP" field of the HTTP Request sampler.




Be aware of existence of the alternative way of recording a JMeter test which automatically detects handles dynamic parameters so you will not have to worry about extracting and substituting dynamic values. Check out How to Cut Your JMeter Scripting Time by 80% article for more details






share|improve this answer




















  • I solved it, by using Bean Shell Pre-Processor, Thanks :)
    – shank
    Nov 21 at 12:32










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53255912%2fhow-to-send-authorization-code-from-1-api-to-another-api-using-regular-expressio%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














The error you're getting is not related to the Regular Expression Extractor at all, it is about some HTTP Request sampler having incorrect hostname



As far as I can see you can successfully extract the header value, but you should not be using it as the hostname, most probably it should go:



  • as one of the request parameters (i.e. directly in body or as a part of the URL)

  • as a HTTP Cookie

  • as a HTTP Header

So you need to find out how the token should be passed and provide the variable from the regular expression extractor there, but it is obviously not "Server Name or IP" field of the HTTP Request sampler.




Be aware of existence of the alternative way of recording a JMeter test which automatically detects handles dynamic parameters so you will not have to worry about extracting and substituting dynamic values. Check out How to Cut Your JMeter Scripting Time by 80% article for more details






share|improve this answer




















  • I solved it, by using Bean Shell Pre-Processor, Thanks :)
    – shank
    Nov 21 at 12:32















0














The error you're getting is not related to the Regular Expression Extractor at all, it is about some HTTP Request sampler having incorrect hostname



As far as I can see you can successfully extract the header value, but you should not be using it as the hostname, most probably it should go:



  • as one of the request parameters (i.e. directly in body or as a part of the URL)

  • as a HTTP Cookie

  • as a HTTP Header

So you need to find out how the token should be passed and provide the variable from the regular expression extractor there, but it is obviously not "Server Name or IP" field of the HTTP Request sampler.




Be aware of existence of the alternative way of recording a JMeter test which automatically detects handles dynamic parameters so you will not have to worry about extracting and substituting dynamic values. Check out How to Cut Your JMeter Scripting Time by 80% article for more details






share|improve this answer




















  • I solved it, by using Bean Shell Pre-Processor, Thanks :)
    – shank
    Nov 21 at 12:32













0












0








0






The error you're getting is not related to the Regular Expression Extractor at all, it is about some HTTP Request sampler having incorrect hostname



As far as I can see you can successfully extract the header value, but you should not be using it as the hostname, most probably it should go:



  • as one of the request parameters (i.e. directly in body or as a part of the URL)

  • as a HTTP Cookie

  • as a HTTP Header

So you need to find out how the token should be passed and provide the variable from the regular expression extractor there, but it is obviously not "Server Name or IP" field of the HTTP Request sampler.




Be aware of existence of the alternative way of recording a JMeter test which automatically detects handles dynamic parameters so you will not have to worry about extracting and substituting dynamic values. Check out How to Cut Your JMeter Scripting Time by 80% article for more details






share|improve this answer












The error you're getting is not related to the Regular Expression Extractor at all, it is about some HTTP Request sampler having incorrect hostname



As far as I can see you can successfully extract the header value, but you should not be using it as the hostname, most probably it should go:



  • as one of the request parameters (i.e. directly in body or as a part of the URL)

  • as a HTTP Cookie

  • as a HTTP Header

So you need to find out how the token should be passed and provide the variable from the regular expression extractor there, but it is obviously not "Server Name or IP" field of the HTTP Request sampler.




Be aware of existence of the alternative way of recording a JMeter test which automatically detects handles dynamic parameters so you will not have to worry about extracting and substituting dynamic values. Check out How to Cut Your JMeter Scripting Time by 80% article for more details







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 12 at 6:38









Dmitri T

68.6k33458




68.6k33458











  • I solved it, by using Bean Shell Pre-Processor, Thanks :)
    – shank
    Nov 21 at 12:32
















  • I solved it, by using Bean Shell Pre-Processor, Thanks :)
    – shank
    Nov 21 at 12:32















I solved it, by using Bean Shell Pre-Processor, Thanks :)
– shank
Nov 21 at 12:32




I solved it, by using Bean Shell Pre-Processor, Thanks :)
– shank
Nov 21 at 12:32

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53255912%2fhow-to-send-authorization-code-from-1-api-to-another-api-using-regular-expressio%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3

Museum of Modern and Contemporary Art of Trento and Rovereto