Query strings with HTTP URL - html

I am trying to do a HTTP GET of an URL with multiple query strings using a browser. Following is my observation
http://192.168.0.1:80/mycontent/?key1=value1 //Works.
http://192.168.0.1:80/mycontent/?key1=value1&key2=value2 //Doesen't work.
The question here :
I am finding a hard time to figure out what's the right format to
append the query string
Should we use &amp when we put in the browser?
Is there a way that I can find the validity (availability in the server) of the query string I enter in the URL.

You should use & when writing the link into HTML, for example:
Example
But not when entering the URL into the address bar, or using it directly in JavaScript (for example).
Your format is correct, so you should be able to pick up both key1 and key2 in the request collection. Depending on the language you are using on the server, the technique for this differs.

Related

How to Search Access DB and Make A DB Wide Search & Replace Operation

we have an access database. We had been using http://www.example.com on various data sections. Now we want to search this URL and replace all occurrences.
I am not sure if Find and Replace utility works in this case. Because Look in field is set to Current Document but my search does not bring expected results.
The goal is only changing domain name so any URL that starts with http://www.example.com will be updated and URLs will start with http://www.newexample.com
One thing that comes to my mind is exporting 40 tables as CSV and doing the operation via Notepad++ and import the resulting CSV file back to database.
In the Find and Replace dialog, make sure that Match is set to Any Part of Field.

What is the URL when I DELETE an object

I'm running a local server playing around with an API using Django. I have a model called 'Users' populated with a few objects, and am using DefaultRouter.
I want to know what the URL would be if I were to DELETE a specific object from this model. For example, if I wanted to GET a user with an ID of 1 in this model, the URL would be: "localhost:8000/Users/1/". What would the equivalent be to DELETE this user?
I found an explanation of this on the REST API website (below), however, I don't understand what any of the syntaxes means.
What is {prefix}, {url_path}, {lookup} and [.format]? If anyone could provide an example of what this might be using a localhost that would be really helpful.
Thanks
Let us take an example of an API (URL) to update book data with id (pk) being 10. It would look something like this:
URL: http://www.example.com/api/v1/book/10/
Method: PUT/PATCH
With some data associated.
If you want to delete you just need to change method to DELETE instead of put or patch.
Regarding your second question lets compare the url with the parameters.
prefix: http://www.example.com/api/v1/book
lookup: 10
format: It specifies what type of data do you expect when you hit the API. Generally it is considered to be json.
url_path: In general, every thing after look up except query string is considered to be url_path.

How to include SR related work log long description when using maximo oslc rest api?

I am doing an HTTP GET request to /maximo/oslc/os/mxsr and using the oslc.select query string parameter to choose:
*,doclinks{*},worklog{*},rel.commlog{*},rel.woactivity{*,rel.woactivity{*}}
This lets me get related data, including related worklogs, but the worklog does not include the 'description_longdescription' field.
The only way I seem to be able to get that field is if I do a separate HTTP GET to query a worklog id directly through /maxrest/rest/mbo/worklog . Then it provides the description_longdescription field.
I understand this field is stored separately through the linked longdescription table, but I was hoping to get the data through the "next gen" oslc api with one http get request.
I've tried putting in 'worklog{*,description_longdescription}', as I read somewhere that longdescription is a "non-persistent" field and must be explicitly named for inclusion, but it had no effect.
I figured out that for the /maximo/oslc/os/mxsr object in the API, I needed to reference the related MODIFYWORKLOG object through the rel.modifyworklog syntax in the oslc.select query string:
oslc.select=*,doclinks{*},rel.modifyworklog{*,description_longdescription},rel.commlog{*},rel.woactivity{*,rel.woactivity{*}}
I also had to explicitly name the non-persistent field description_longdescription for it to be included.
Ref. for the "rel." syntax: https://developer.ibm.com/static/site-id/155/maximodev/restguide/Maximo_Nextgen_REST_API.html#_querying_maximo_asset_management_by_using_the_rest_api

Google charts api removes part of string when creating qr code in sheets

We want to create a qr code in google sheets that opens a form with filled in values.
This is the url we want to create:
"https://docs.google.com/forms/d/e/1FAIpQLSeSsFWHuQt1qdeymL3IUHftT3dh54FNTmG6NrDhcBrqFBIoZQ/viewform?usp=pp_url&entry.1299510889=Grosemans+Kurt+-+4&entry.619773178=A&entry.1305845422=2"
We make the qr code with following formula:
=image("https://chart.googleapis.com/chart?chs=250x250&cht=qr&chl="&CELLREFERENCE)
However the charts api removes the parameters from the string and only redericts to the form without the filled in parameters.
(this is removed from the string: &entry.1299510889=Grosemans+Kurt+-+4&entry.619773178=A&entry.1305845422=2)
How can we solve this?
By concatenating the URL as you are currently doing, the resulting URL looks like the following:
https://chart.googleapis.com/chart?chs=250x250&cht=qr&chl=https://docs.google.com/forms/d/e/1FAIpQLSeSsFWHuQt1qdeymL3IUHftT3dh54FNTmG6NrDhcBrqFBIoZQ/viewform?usp=pp_url&entry.1299510889=Grosemans+Kurt+-+4&entry.619773178=A&entry.1305845422=2
This may not seem wrong at first, but the issue is that the query parameters of the QR code's URL are understood as part of the top-level URL. i.e.
Base URL: https://chart.googleapis.com/chart
Query strings:
cht=qr
chl=https://docs.google.com/forms/d/e/1FAIpQLSeSsFWHuQt1qdeymL3IUHftT3dh54FNTmG6NrDhcBrqFBIoZQ/viewform
usp=pp_url
entry.1299510889=Grosemans+Kurt+-+4
entry.619773178=A
entry.1305845422=2
In order to obtain the the result you are looking for, you must use the ENCODEURL function as following:
=image("https://chart.googleapis.com/chart?chs=250x250&cht=qr&chl="&ENCODEURL(CELLREFERENCE))
This will result in:
Base URL: https://chart.googleapis.com/chart
Query strings:
cht=qr
chl=https://docs.google.com/forms/d/e/1FAIpQLSeSsFWHuQt1qdeymL3IUHftT3dh54FNTmG6NrDhcBrqFBIoZQ/viewform?usp=pp_url&entry.1299510889=Grosemans+Kurt+-+4&entry.619773178=A&entry.1305845422=2
I hope this is useful to you. Regards.

GET and POST values in the same link

I want something like this:
link
GET and 2x POST in hyperlink. How can I do that? Nothing wants to work
I have a GET array in PHP and I want to generate a link which leads to the correct url to give me those GET variables.
You can't have 2 GET variables with the same name. You can arrange them into an array as follows:
link
Just for clarification, this is still a GET request, links cannot normally produce a POST request, nor you should try to achieve that not-normally.
EDIT: To answer OP's calrification.
If you have a $_GET array, and you want to generate a link to get you there, you can use http_build_query()
I don't think you understand what GET and POST means in the HTTP world. Any items you put on a query string of a URL are GET parameters, you can't have 2 with the same name. POST parameters are sent as a part of the request, not as a query string on the URL.
GET and POST are http operations.
Sending values by using the ? as a separator in the url is different but related. eg:
foo.com/page.php?val1=1&val2=2
The values are called Query String values.
For GET operations, values are sent as a query string values. For POST operations, the values are sent in the body of the POST request. This is why POST must be used when a lot of data is being sent to the server. (Query strings have a maximum length, HTTP requests do not.)
You can do a POST operation to a url that includes query string values. This is more common with Ajax requests but can be done in a form as well. Just set the action url to something like index.php?val1=1&val2=2 the form's (additional) values will be sent as the http body. Remember to set method="post" in the form.
Note that you will need to create the query string yourself in this example, including escaping it properly.
Repeating value names in the query string values
Usually this causes both values to be sent, but the server overwrites the variable and ends up only presenting the last one to the client software.
So if you use a url such as
<a href="http://localhost/index.php?get=abc&post=cde&post=efg">
// It will be decoded by php and most server-side frameworks as
set get to abc
set post to cde
set post to efg
Result: 2 variables, get and post
There is nothing in the HTTP standard that says you can't send two query string params with the same name. However, you won't be able to use $_GET to retrieve these values; $_GET will pick up the last one. Instead, you'll have to manually parse $_SERVER['QUERY_STRING']. It's not that hard and I've done it a number of times when PHP has to handle a URL pattern generated by a third-party tool. If you're feeling really fancy you can have your query-string parse routine generate a $_GET member as an array if more than one instance of that member is encountered.