How to enter x-auth header in postman? - api

So I receive an API credential that asks me to enter an X-AUTH-HEADER and Content-Type.
In my postman, on the "Headers" tab, there's a "Content Type" key but I can't see an "X-Auth-Header" key. I only have "Authorization" key. Where to I enter the X-Auth-Header key then?

Custom Headers can just be manually added to the Headers section in Postman.

Just enter header name and value. You can enter anything you like -- not restricted to suggested options

Related

How to get request headers in instagram.com

I'm working on a small-scale instagram scraping project mainly using selenium and the python requests module. I discovered that when the Request Header changes for www.instagram.com, the text that I get from using
requests.get("https://www.instagram.com/<address>/?__a=1")
Returns the HTML code for the webpage. Instead I was expecting it to be the json text containing post details. Currently, it works fine if I change the headers manually.
How do I automatically get the request header using selenium or requests? I'm expecting to get the text labeled in the image attached:
www.instagram.com Request Header
Thank you.
import requests
response = requests.get("https://www.instagram.com/<address>/?__a=1")
print(response.status_code)
print(response.headers)
print(response.json())
As I see in the headers printed out on to console, there is a set-cookie header. If this is something that you are looking for, then you may use this line to extract only this header:
print(resp.headers['Set-Cookie'])

HTML page got returned as part of API response in karate. Now how to enter username and password on that?

I have an API which redirects to browser and on that we have to enter username and password.
The API returns the HTML page as part of the response. How from HTML response we can pick username and password via locator Id and click button?
I have tried below but as it is returned in the response I somehow need to tell where in response find that field and input.
And input('#username', 'username')
And input('#password', 'password')
When click('#kc-login')
What I would do is scrape any information needed out of the HTML like this: https://stackoverflow.com/a/61605535/143475
And then form an HTTP request to do what the clicking of the button actually does. Remember no matter what HTML and complex JS / UI you see, finally everything becomes some HTTP request. Use the developer tools "network" part of the browser to figure this out.
The rest is up to your creativity. Work with some web-developers if required.

How to remove (not modify) a request header in a Firefox addon?

I am using nsIHttpChannel in an observer to modify outgoing request headers, which works fine. According to the API, however, it appears I cannot simply remove a header (as I can in Chrome), I can only give it an empty value via setEmptyRequestHeader(). Is there some other way to completely remove the header from the request ?
The documentation for setRequestHeader() states
If aValue is empty and aMerge is false, the header will be cleared.

Passing matrix parameter in Postman

i'm trying to test some REST's API with Postman. When I click on Params button and enter a key and value my URL is something like www.example\rest\api?key=value, my API does not support query parameters, is there any way to pass like a matrix parameter something like www.example\rest\api;key=value or should I enter manually in URL area?
If your API expect the input as part of the request body you should pass the keys/values using the form-data button in Postman.

Set Accepts in HTTP Download Request Header

I have a WCF Web Api endpoint that returns an invoice: http://localhost/api/invoice/23
The format it returns is that of the accepts header in the request. If the Javascript wants JSON or XML then it just sets this in the accept header. This is how WCF Web Api seems to work. I've added a PDF formatter to invoice so that when asking for application/pdf it will get a rendered pdf file stream back with the appropriate MIME type. This works fine and I can test it in fiddler.
I need the user to click something in the browser to start the PDF download and pop up the open/save dialog. I don't know how to do this and set the accept header of the request. Static links or window.location in javascript won't work because it doesn't let me set the header. AJAX request won't work because although I can set the header, it expects text back and it won't show as a download in the browser.
I'm not sure how I can do this. Any suggestions would be greatly appreciated.
You can just dynamically create a form in JavaScript and ask it to start in a new tab. That should give you what you want.
function SubmitRequest()
{
var myForm = document.createElement("form");
myForm.method = "post";
myForm.action = "url here"
var myInput = document.createElement("input");
myInput.setAttribute("name", "json");
myForm.setAttribute("target", "_blank");
myInput.setAttribute("value", "Your value here");
myForm.appendChild(myInput);
document.body.appendChild(myForm);
myForm.submit();
document.body.removeChild(myForm);
}
The easiest way is to add an A tag in your page with a link to http://localhost/api/invoice/23.pdf and then use the AddUriPathExtensionMapping on your formatter to have it generate the accept header automatically from the path extension on the URI.