Getting Documentation Json Instead Of Real Data From Api Calls

Discussion in 'Shapeways API' started by scott_reece, Jul 24, 2017.

  1. scott_reece
    scott_reece Member
    When I make a GET request to to get a list of materials, all I get is the documentation JSON instead of real data. I'm passing my "access_token" from my OAuth2 request into the "Authorization" header, which I receive in the following format:

    "access_token": "ACCESS_TOKEN",
    "token_type": "bearer",
    "expires_in": 3600,
    "refresh_token": "REFRESH_TOKEN"

    So here are my questions:
    1. Is even the right URL to get a list of all Shapeways materials, or is that just the documentation URL?
    2. Am I passing in my access_token correctly, by adding it as an HTTP header called "Authorization"?
    3. Is there anything else I'm missing to get real data instead of the JSON documentation?

    If it makes any difference, I'm using the WebClient class in C#.

  2. imdaveho
    imdaveho Shapeways Employee Product Team
    are you setting up the Authorization header as Authorization: Bearer <access_token> ?

    I haven't set things up manually (used OAuth2 libs) but testing it on Postman, it seems that you might not bet setting the Auth header to share a gist or snippet?
  3. scott_reece
    scott_reece Member
    Thanks Dave. You were correct, and the wording in your reply gave me what I needed to get the Authorization header correct. Here is my working C# code, if it helps anyone else. I can also provide my OAuth2 class if anyone wants it.

               //Get the token with my own OAuth2 class
                var auth = new OAuth2("", ConfigurationManager.AppSettings["ShapewaysClientID"], ConfigurationManager.AppSettings["ShapewaysClientSecret"]);
                var tokenResult = auth.GetToken();
                using (var client = new WebClient())
                    //Add the access token to the API request
                    client.Headers.Add("Authorization", "Bearer " + tokenResult.AccessToken);
                    var url = "";
                    //Make the request
                    var result = client.DownloadString(url);
                    //Parse the returned JSON object
                    return JObject.Parse(result);