how to get the value of special character like #,?,; - web-services

I am using Advanced Rest Client plugin in Google Chrome.
URL: http://localhost:6721/bgs/ujh/data# or data? or data;
method: GET
When I pass this data in my controller I am getting data only instead of data# or data? or data;.

You should urlencode the data. # for example would become %23
http://localhost:6721/bgs/ujh/data%23

The # character indicates a fragment. It is not sent as part of a HTTP request. It is only used within the browser to navigate to a part of a page. That's why you are only seeing data; the fragment component of the URL is being stripped.

Related

How to get All element url in wso2ESB

I am working on wso2ESB version 4.9.
I have these URL:
http//192.168.0.1/getinfo/id=10&name=alice&from=AU$code=ddddd
http//192.168.0.1/adduser/id=11&name=bob&from=USA&tel=25644&city=newyork$code=ddddd
So i want get all of element of URL and separate code and call web-service without code variable . My URL element is changing but always has code variable.
Thanks
You can read query param string inside a script mediator (javascript). You can read it like this and manipulate as per your need. Then you can append it to the outgoing request.
mc.getProperty('QUERY_PARAMS')

How to send POST variable in POSTMAN

I can't get POSTMAN to send any post variables to my Django app. Suppose I have a post variable called 'report_request' and it has a value that is a JSON string. On the Django side I want to get request.POST['report_request'] and parse the JSON into a dictionary. But POSTMAN never seems to send the POST data. How exactly do I do this? Is there some magical header I need to send?
Doh! My bad. The URL I need to connect to is really HTTPS rather than HTTP, but I was specifying the URL as http://. Apparently if Postman is asked to connect to an HTTPS site using HTTP, it silently just drops all POST variables. How lovely. Anyway it was an easy fix, just change the http:// url to https:// and all is well.
Be sure to provide the POST data in the body (body tab) of the request and not in the parameters (params tab).
Otherwise, POSTMAN will interpret your POST request as being without data and on a url with GET parameters.
See these specifications about csrf if needed
Check if you're sending the csrf token, it's a security feature.
https://docs.djangoproject.com/en/1.8/ref/csrf/

django and angular url patterns

Sometimes in my code I pass get parameters with URL's. One particular scenario is if the user is not logged in, but puts a URL for a page that requires login, they will be required to login first.
In that case I may have a URL such as: www.example.com/home/#/main/.
The end of the URL /#/main/ is for angular. However, in django when I do the below to get the next parameter above, I do this:
self.request.GET.get('next', self.redirect_url)
The problem is that in this case, next provides everything but the angular portion, so I get: www.example.com/home/.
Is there anyway to get the remaining portion of the URL as well?
You have to urlencode the url before you add it as a parameter. Then it will turn into %23 and insn't the separator for the anchor anymore, which is handled client side only as KVISH described.
Apparantly you can't. Django doesn't even see the anchor, its all handled on client (browser).
How to identify an anchor in a url in Django?
The way I got around this is I use jQuery to set a hidden input field to the hash location, which can be obtained like so:
window.location.hash
The hash gets submitted with the form and I can take it from there.

How to distinguish between a data uri and an image url?

I have a php script that handles the url sent to it via ajax from a js file. This is either a data uri or an image url. What would be the best way to distinguish whether the string supplied is a data uri or an image url, from the php script. I was thinking of using a regex to test the data uri. But i dont seem to come with a right regex that can handle the data uri.
Well... if it starts with data: then it's a data URL. So... if( substr($url,0,5) == "data:") should do it.
Remember: KISS.
Check the extension of the URL.
Regex: \.[^\.]*$

ajax request not sent in IE6

I am developing a webpage with all actions handled as ajax.It works fine in firefox,IE 8,7.But in IE 6 no request is being sent to the sever.Why does this happen.I amusing jquery.getjson and jquery.colourbox methods to fetch data and display in colorbox.
Change Password<span class=""></span> $('a.changepass').colorbox();
This is the html code and i need to open the contents of returned response in colorbox.This works fine with IE 7,8 and firefox.
I guess, this maybe a cache problem.
IE try caching everything requested from a url.
if u request the same url for 2nd time, ie will return the old data by 1st request without any network.
to solv ie's url cache, adding a "?" or current timestamp param to request url.
http://abc.com/ajax?t=123455
Have you read this about the UTF-8?
http://firelitdesign.blogspot.com/2009/07/jquerys-getjson.html