I am trying to get on specific object of my model which has "#" in its name ex:obj#1 like this, but when I use this object to retrieve its related attribute I am getting error like below:
"error-message": "Request could not be completed because the relevant data model content does not exist"
can you please suggest me any way to request my object in postman?
Do you use "#" in the URL? It is a reserved character and needs to be encoded.
Here you can see the reserved URL characters and how to encode them:
https://en.wikipedia.org/wiki/Percent-encoding
Related
I am creating a new event in google calendar by the following URL structure.
https://calendar.google.com/calendar/r/eventedit?
text=discount for Asgardian&
dates=20200327T032400Z/20200327T032400Z&
details=Thor will be there to receive you&
location=Asgard&
trp=false&sprop=&sprop=name:
here is a URL variable text, which represents the title of an event.
if I pass a plain string, it works well. but if I pass special character like '%' (e.g. 20% off for Asgardian), then google calendar gave me -
Bad Request
Error 400
how can I pass '%'?
(same error for details vaiable also)
in the comment, #terry gave me answer for how to pass % through URL.
I need to encode it as %25.
he also share that - Javascript has a built-in function for this URL encoding. encodeURIComponent()
if we wrap our string by encodeURIComponent(), it'll give us URL encoded string.
thanks.
The URL of the template is:
http://localhost:8080/login?error=Usu%E1rio%20inexistente%20ou%20senha%20inv%E1lida
where, for example, %E1 is á
I'm trying to display the value of the param error on the page using this code:
but a wrong value with special character is being displayed.
Welcome to SO.
I see two ways you can try:
1) Use the utility for an HttpServletRequest:
<p th:utext="${#httpServletRequest.getParameter('error')}">[error message]</p>
This is getting the value of the error parameter from the request.
2) Use the typical usage for getting the value of a param:
<p th:utext="${param.error}">[error message]</p>
In either case, you can use th:if to check for null. You can use utext to get the unescaped text so that unusual characters display.
Also, check that your character encoding is set to UTF-8. In your config, it would look something like:
resolver.setCharacterEncoding(StandardCharsets.UTF_8.name());
or
resolver.setCharacterEncoding("UTF-8");
Instead of trying to decode the URL, I first encoded the error message where it was generated using URLEncoder.encode(errorMessage). So, the URL changed to http://localhost:8080/login?error=Usuário+inexistente+ou+senha+inválida. Then, I didn't need to decode. I only used th:text="${param.msgError}
I created a hyperlink to a file. the file name contains hashtags as a means to separate information.
<div style="height:100%;width:100%">.</div>
translated to...
http://localhost/dir/upload/1427853638#0#file#A101.pdf
Is this a "legal" name in a URL? Im getting a "file not found" error
The requested URL /dir/upload/1427853638 was not found on this server.
So, clearly the # has another meaning in the URL (I understand now, its a location hash property). Is there a way to get this to work, or do i need to use another character besides the # in the file names?
Since # is a special character in the URL semantic (it's used to provide an internal anchor in a HTML page), it should be URL-encoded into %23.
Your URL should be: http://localhost/dir/upload/1427853638%230%23file%23A101.pdf.
NB: you can find an online URL encoder here: http://meyerweb.com/eric/tools/dencoder/
I've tried send request like this.
localhost:3000/ws/job_histories/index?agent_id=#1000
But on Controller I've received agent_id='' or like this one
localhost:3000/ws/job_histories/index?agent_id=10#00
I've received agent_id='10'. I think problem has because Rails understand it like comment.
How can I correctly received my data. Rails doesn't give me any exception.
The hash symbol is the fragment identifier and your browser will not send it to the webserver ever.
If you want to send it you need to URL encode it (%23), you can achieve that with CGI.escape('#').
This is completely normal, hashes belong to the client, they are not sent to the server.
And # is what represent a hash so remove it or encode it
Hash fragments aren't sent to servers from the browser, so this would never work, for any server-side framework, not just Rails.
From Wikipedia, Fragment identifiers:
Clients are not supposed to send URI-fragments to servers when they retrieve a document...
From URL Fragments and Redirects:
The Fragment component of the URL is the end of the URL from the hash symbol (#) onward. URL Fragments are never sent to the server in the HTTP request...
I've been dealing with a "soap message header incorrect" error message when submiting a SOAP request using Savon.
I copy/pasted the exact same xml generated by Savon into SOAPUI and I don't get that error and I get the expected response.
So, since I'm tired of trying different things, I want to assemble my own header without Savon help on that.
What I want to do is something like:
soap.header = "<wbs:Session><wbs:SessionId></wbs:SessionId><wbs:SequenceNumber></wbs:SequenceNumber></wbs:Session>"
However I get this error from Savon:
can't convert Symbol into String
Why?
Thank you in advance.
Its likely caused by the fact you havent set any values.
I was getting this error when I had a hash containing just one custom object on return, as it was trying to access parts of the hash that had automatically been removed. (it removed unnesscary layer of hash for me :#)
I believe the header will only accept a Hash - from the savon.rb page:
Besides the body element, SOAP requests can also contain a header with
additional information. Savon sees this header as just another Hash following
the same conventions as the SOAP body Hash.
soap.header = { "SecretKey" => "secret" }