I'm trying to parse my URL with wildcards. The problem appears when I try to parse long strings with a wildcard. For example, my URL looks like this:
http://testapi.com/v1/cards/%s/reissue?DesignId=%s&Comment=%s
and this is my code:
get_object.setRestUrl(String.format(url, card_id, design_id, comment))
When comment = "Something" it works, but when comment = "Something something", it goes on an error and says that it is "Unable to parse HTTP request".
How is it possible to make suitable my code with long strings with wildcards? I know that when typing long string it gives URL that looks like this:
http://testapi.com/v1/cards/1/Block?reasonId=1&comment=Something%20like%20that%20example
Just needed to modify with comment.replace(" ", "%20"), and now it works fine, even when there are no spaces.
Source : https://forum.katalon.com/t/getting-an-error-unable-to-parse-http-request/17685
P.S
If it is not allowed to post answer from another site, I will remove it.
You could try it:
get_object.setRestUrl(String.format(url, card_id, design_id, comment.replace(" ", "%20")))
More information could be found at https://forum.katalon.com/t/getting-an-error-unable-to-parse-http-request/17685
Related
I've got this string that I want to send to a backend. In this string, there are several forward slashes, that is basically code that is commented out. It could look like:
val string = "// SOME STUFF
// OTHER TEXT ***************************************************
// THIS WOULD CONTINUE FORWARD"
So to escape this entire String, I'm using Gson().toJson(string). This would give a result like
"// SOME STUFF\r\n\r\n// OTHER TEXT ***************************************************\r\n// THIS WOULD CONTINUE FORWARD"
But if I put this into a website that can escape strings for me, I would get
"\/\/ SOME STUFF\r\n\r\n\/\/ OTHER TEXT ***************************************************\r\n\/\/ THIS WOULD CONTINUE FORWARD"
This bottom part, is what the backend would accept, and the top part it rejects. Is there any way I can do this in a different way, to make Gson look like the bottom part? This is sent as JSON btw, so as
{
"stuff": "THE ESCAPED STRING"
}
I kind of failed, and the Gson library didn't help at all. Ended up using Apache's StringEscapeUtils to fix the issue for me, with the StringEscapeUtils.escapeJson method.
I am trying to retrieve data from cloudSearch, searching for the word "Person" and adding the following filter:
(prefix field=claimedgalleryid '')
The problem is that I don't know how to create the URL using that exact filter.
Could someone give me a suggestion or some link to Amazon documentation related to this topic?
What I've tried and didn't work:
...search?q=Gallerist&size=10&start=0&fq=(prefix%20field=claimedgalleryid%20%27%27)
...search?q=Gallerist&size=10&start=0&filter=(prefix%20field=claimedgalleryid%20%27%27)
You were close with your first attempt--it looks like you forgot to URI encode the = sign as %3D. Try this instead:
&fq=(prefix+field%3Dclaimedgalleryid+'')
I highly recommend using the "test search" feature to work out the kinks in your query syntax. You can see the results right there, and then use the "View Raw: JSON" link to copy the full request URL and see how characters get escaped and such.
I'm trying to get a web page using vb.net and HtmlAgilityPack with this code:
Dim mWPage As New HtmlAgilityPack.HtmlDocument
Dim wC As New WebClient()
mWPage.Load(wC.OpenRead(mUrl))
My problem is to get text from a table but, when I extract InnerText, i get something like this:
Modificat<!--span-->i dati
instead of (Note that I wrote the same string and below it's displayed correctly):
Modificati dati
I've tryed to use the answer here but it doesn't work in this case (or I wasn't able to make it works)
I noticed that contents changes when I change "User-Agent", so I tryed various "User-Agent" but I never got a perfect text.
So my questions are:
can I use the code that is indicated in the answer to solve the problem?
if not, can I get a perfect text using the right "User-Agent"?
If so, how can I find the right "User-Agent"?
If not, how can I fix the receivedstring?
The response from the server based on a new User-Agent is fully dependent on the server so we will not be able to predict which one will yield the response you're looking for.
But... You will be able to use the HttpUtility.HtmlDecode method to get rid of the encoded HTML and turn it into teh string you're looking for.
To filter out the HTML comment you may need to change the XPath you're using. If you append //text(), you should get only the text elements that match the rest of your expression.
I have been beating my head against the wall with this one. The url must contain \r\n at the end or the device I am connecting to will not recognise it. I did not create the device so I can't go in and change what it is looking for. I also can not use the percent values for them either. When I create the URL from a string the URL becomes nil because it does not like the \r\n. I have searched on here all day. Literally and have come up with nothing. If anyone has a suggestion please let me know. I would really appreciate it.
Edit.. The url is #"http://192.168.1.1/link.html?cmd=scan\r\n"
I was able to figure out another way in so I did not have to send the string like that. Thank for the help.
Try this:
NSLog(#"http://192.168.1.1/link.html?cmd=scan\\r\\n");
OutPut:
http://192.168.1.1/link.html?cmd=scan\r\n
You have to skip the "\" with just putting another "\".
I want to be able to read the cookies from Apache's HTTP_COOKIE string and then add includes based on the contents of that string.
I've got this far:
<!--#set var="cookies" value="HTTP_COOKIE" -->
<p>COOKIES: <!--#echo var="$cookies"--></p>
which gives me a string with all the cookies in it.
Now I want to be able to parse the string for something like Name=Bob.
I thought I'd be able to do this:
<!--#if expr="$cookies = /Name=([a-zA-Z]+)/"-->
<p>Your name is <!--#echo var="$1"--></p>
<!--#endif-->
But it doesn't seem to work. What should I be doing -- or isn't this possible?
This is definitely possible -- see the get_include_var function of mod_include.c.
Perhaps your regular expression needs some tweaking.