How to set custom User-Agent in Paw? - user-agent

By default, Paw sets the User-Agent to something like Paw/2.3.4 (Macintosh; OS X/10.11.6) GCDHTTPRequest. Is there any way to tweak that for testing purposes? I know I can just use curl, but I really like Paw.

If you want to tweak the User-Agent, you can just change it like any other request header.
Click on "Headers" in the Request Composer in Paw. (This should be under the URL bar.)
Click on 'Add Header Name' and enter User-Agent.
Click on 'Add Value' and enter your desired User-Agent, or leave it blank.

Related

How to set a session id in Postman

I need to hit a post request to an API service which requires a session id along with other parameters in its post request field in order to get the required information.
I am using Postman to test this API.
I would like to know how to send a 'session id' in a post request when using Postman?
I am aware of pre-request script in Postman, but I am unaware of how to use the variable in post request.
In Postman native app:
Turn on the Interceptor.
Go to Headers
Key: Cookie
Value : sessionid=omuxrmt33mnetsfirxi2sdsfh4j1c2kv
This post is bit old but I want to still answer incase someone else is looking for an answer.
First, you need to see if intercepter is enabled in the toolbar, it is present one step away from sign-in
If does not not get enabled when you click on it, you can install extension. I think there is one for Chrome. Go ahead and add the extension.
After that you can go back to Postman and enable intercepter
You will be able to see cookies in postman and at this point you can add _session_id
I hope this will help.
Thanks,
Hit inspect on the site you are working on, when logged in
On your Chrome/browser, go to application - cookies.
Copy your PHPSESSID.
On postman headers Key: Cookie
Value: PHPSESSID=dsdjshvbjvsdh (your key)
For standalone Postman app
You can use global variables in postman. First in the Tests tab of the first request set the session as global variable:
var a = pm.cookies.get('session');
pm.globals.set("session", a);
It might be 'session_id' as well (check in the headers of your first request) instead of session. To check if this variable is set, after you do your first request, go to the gear icon and click on globals.
Then go to your second request -> Headers and for key add 'Cookie' while for value add 'session={{session}}'
Side note: be careful not to save keys that are used by your framework or they might be deleted for some reason.
On your browser:
Open the developer tools (right click and Inspect).
Go to Application Tab > Storage > Cookies.
Open your site Cookie and copy the Name and Value.
In Postman 8+:
In your Request tab, go to Headers.
Click in the eye icon to see the hidden headers.
Click in the "Cookie" link that is in the top right corner.
In the "Manage Cookies" popup, select your domain, click on "+Add" button, or edit the existent cookie.
Paste the values that you copy from the browser. The complete value will look like PHPSESSID=f20nbdor26v9r1k5hdfj6tji0p; Path=/;
Click on "Save", and close the popup.
Select Tests Section below the Request URL
if(postman.getResponseHeader("authorization")!==null)
{
postman.setGlobalVariable("token","Bearer " + postman.getResponseHeader("authorization") );
}
Here u can use SessionId to get SessionId from Header and put in global variable .

Windows forms navigate webrowser method not available?

I try to navigate to a url and send a new http header with phalanger but when I use the navigate method it gives me an error message there is no method available (even with overload and so). How can I send my own http header? Example:
This dosesn't work:
this->browser->Navigate(new \System\Uri($url),"_self",null, $authHeader);
This works (but it navigates only to the website w/o sending my header:
this->browser->Navigate(new \System\Uri($url),$authHeader);
Edit: This works, too, and is the more correct approach but I want the thing with the additional header!!!
this->browser->Navigate(new \System\Uri($url));

Why does requests library fail on this URL?

I have a url. When I try to access it programmatically, the backend server fails (I don't run the server):
import requests
r = requests.get('http://www.courts.wa.gov/index.cfm?fa=controller.managefiles&filePath=Opinions&fileName=875146.pdf')
r.status_code # 200
print r.content
When I look at the content, it's an error page, though the status code is 200. If you click the link, it'll work in your browser -- you'll get a PDF -- which is what I expect in r.content. So it works in my browser, but fails in Requests.
To diagnose, I'm trying to eliminate differences between my browser and Requests library. So far I've:
Disabled Javascript
Disabled (and deleted) cookies
Set the User-Agent to be the same in each
But I can't get the thing to work properly in Requests or fail in my browser due to disabling something. Can somebody with a better idea of browser-magic help me diagnose and solve this?
Does the request work in Chrome? If so, you can open the web inspector and right-click the request to copy it as a curl command. Then you'll have access to all the headers, params, and request body, which you can play around with to see which are triggering the failure you're seeing with the requests library.
You're probably running into a server that discriminates based on User-Agent. This works:
import requests
S = requests.Session()
S.headers.update({'User-Agent': 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)'})
r = S.get('http://www.courts.wa.gov/index.cfm?fa=controller.managefiles&filePath=Opinions&fileName=875146.pdf')
with open('dl.pdf', 'wb') as f:
f.write(r.content)

WP7 - Prevent RestSharp from caching

I use RestSharp in my Windows Phone 7.1 project.
My problem is RestSharp always cache response data.
Example:
At the first time I send request, it returns data correctly. After some delete operations, I send that request again, but response seems the same as the first time, nothing's changed.
If I stop debugging and press F5 to start again, it works perfectly as expected.
I also tried request.AddParameter("cache-control", "no-cache", ParameterType.HttpHeader); and got no luck.
How can I fix this problem?
I have the same issue so just add header that specify not to cache response data
client is my RestClient with base url and than add default header Cache-Control with value no-cache.
client.AddDefaultHeader("Cache-Control", "no-cache")
I found solution in Rico Suter comment, thanks! I will mark this as accepted anwser
its a hack but try something like url = originalUrl + "&nocache=" + DateTime.Now.Ticks
The "Cache-Control" header should do the trick!
I think HTTP Headers are case-insensitive, but the server may not agree with me there! You should try using Cache-Control instead of cache-control...
Also, I would also add the Pragma header with no-cache value to the request (some old servers don't use the "Cache-Control" header, but they will sure recognize this one)!
And I would try to use Fiddler to debug the comms and check that the headers are really being sent to the server as expected!
Another solution can be to set the "If-Modified-Since" header with value of DateTime.Now:
client.AddDefaultParameter("If-Modified-Since", DateTime.Now, ParameterType.HttpHeader);

HTTP request with custom headers fields using Windows Scripts

Is it possible to perform a HTTP Request with specific header fields (like 'referer', 'cookies' or 'User-Agent') using Windows Script Host or any other Windows scripting technology??
Thanks.
Yes (VBScript) :-
Dim oWinHTTP
Set oWinHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
oWinHTTP.Open "GET", "http://remoteserver/thing.ext", False
oWinHTTP.SetRequestHeader "User-Agent", "My Agent String"
oWinHTTP.Send
Using WinHttp gives you the greatest level of control, you can use MSXML2.ServerXMLHTTP.3.0 if you want more effeciently access any XML DOM sent. Using the standard MSXML2.XMLHTTP.3.0 component goes throught WinINet at gives you the users proxy settings and cookie store etc, but reduces your control over the conversation.
Can we set the request header like Cache-control : 'max-age =10000' using jsp / java?
Actually I want to see the previous page with old data on click of browser's back button only if user comes back to this page with in a specified time , say 10 minutes.
Thanks,
Anurag

Resources