|Do you know where your variables are?|
Re^4: Need to resolve the API call queryby davido (Cardinal)
|on Jun 04, 2021 at 17:37 UTC||Need Help??|
Or, for those who prefer to be able to read the code after it's been written, here's a version that is legible:
Now that I can see it legibly, I'm wondering why you are printing the $uri and not doing anything with the $ua->get($uri) response. Additionally, you're using the Dumper keyword without bothering to use Data::Dumper, which means you didn't actually run this test snippet.
However, we can learn something from your code, now that it can be read. Let's remove the useragent portion. Maybe you've got problems there too (why are you using http protocol for oauth, for example), but if we focus just on getting the URI right, you can see there are problems:
Any guesses what the output will be? Here:
Well, that's not a big surprise, now is it? So let's look at what is different. In part of your wanted query string, you see: "%3A%2F%2F". In part of your actually formed query string, you see "%253A%252F%252F". The source string that is producing that is redirect_uri => 'http%3A%2F%2Ftestchandan.com%3A5001'. What do you think is happening here?
Additionally, we see this in your wanted string: "%3A5001", and this in our actually formed URL: "%253A5001". So what is "%3A%2F%2F"? That's "://". And what is "%3A5001"?, that's ":5001". The first one is part of the http://example.com syntax, and the second one is a port specification: example.com:5001. And why are they becoming something different? Because you're double encoding them. It is incorrect to pass this line: redirect_uri => 'http%3A%2F%2Ftestchandan.com%3A5001'. Putting encoding into the redirect_uri is wrong, because the URI module already encodes for you. You should have passed redirect_uri => 'http://testchandan.com:5001', and let URI encode that for you. The double encoding is creating mojibake. Let's fix that part of your code:
And what output do you think we'll get now? Let's see:
Now I don't know if that's your only problem. It seems a little suspicious to not be using SSL for an oauth request, but I don't know how your SSL termination is set up so I can't be sure there. But double-encoding a URL should be pretty obvious if you just take the time to look at your "want" and verify that's what you are forming.
PLEASE, in the future, provide small, self-contained working examples that compile, and that you have run yourself first. And take the three minutes required to format your code legibly, so people can look at it and make sense of it without re-formatting it themselves. How much time do you think we owe you? If the answer is greater than zero you're wrong. Responding here is because we want to be helpful. But by posting incomplete, or overly verbose example code that doesn't compile, is poorly formatted, and that you haven't run yourself is simply an abuse of peoples' compulsion to be helpful.