none
How do I get Postman to call my Web API? RRS feed

  • Question

  • Hello,

    I'm just wondering how I would get Postman, the plugin for Chrome that allows you to test web requests, to call my web API.

    Current, I'm using this AJAX call written in Javascript:

    alert("Getting security token");

    // Do AJAX call to get security token:
    $.ajax({
    url: [security token url],
    type: "POST",
    headers: {
    Accept: "application/json"
    },
    ContentType: "application/x-www-form-urlencoded",
    data: {
    grant_type: "password",
    username: [username],
    password: [password]
    }
    }).done(function(data)
    {
    var accessToken = data.access_token;

    alert(accessToken);

    alert("Getting json string.");

    // Now that we have access token, send it along with the request for the json string:
    $.ajax({
    // meta data sent as URL parameters:
    url: [url to get json string]
    type: "GET",
    headers: {
    Authorization: "Bearer " + accessToken // access token
    },
    contentType: false,
    processData: false
    }).done(function(data)
    {
    $("#jsonDiv").html(data);
    }).fail(function(jqXhr, textStatus, errorThrown)
    {
    alert("jqXhr = " + JSON.stringify(jqXhr));
    alert("textStatus = " + textStatus + ", errorThrown = " + errorThrown);
    }); 
    }).fail(function(jqXhr, textStatus, errorThrown)
    {
    alert("jqXhr = " + JSON.stringify(jqXhr));
    alert("textStatus = " + textStatus + ", errorThrown = " + errorThrown);
    });

    Note that it's a two step process: 1) do an ajax call to the API to get a security token, and then 2) do another ajax call to the API, sending the security token, to do whatever you want (in this case, I'm retrieving a json string).

    What would I have to do in Postman to accomplish the equivalent of this?

    Thanks

    • Moved by CoolDadTx Sunday, June 11, 2017 10:34 PM ASP.NET related
    Friday, June 9, 2017 1:59 PM

All replies