Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

DOL API Examples Not Valid / Errors #67

Open
darth-cheney opened this issue Sep 5, 2016 · 2 comments
Open

DOL API Examples Not Valid / Errors #67

darth-cheney opened this issue Sep 5, 2016 · 2 comments

Comments

@darth-cheney
Copy link

darth-cheney commented Sep 5, 2016

Hi. We have registered and done everything in the steps on the API site, but still cannot get queries to data.dol.gov to return properly (and yes, we are using the key header and token). For example, in the documentation there is the following sample query:

https://data.dol.gov/get/accident/format/xml/limit/10/orderby/desc/columns/{summary_nr:event_desc:event_time}

This ends up returning HTML with an error page:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Error</title>
        <style type="text/css">

::selection { background-color: #E13300; color: white; }
::-moz-selection { background-color: #E13300; color: white; }

body {
    background-color: #fff;
    margin: 40px;
    font: 13px/20px normal Helvetica, Arial, sans-serif;
    color: #4F5155;
}

a {
    color: #003399;
    background-color: transparent;
    font-weight: normal;
}

h1 {
    color: #444;
    background-color: transparent;
    border-bottom: 1px solid #D0D0D0;
    font-size: 19px;
    font-weight: normal;
    margin: 0 0 14px 0;
    padding: 14px 15px 10px 15px;
}

code {
    font-family: Consolas, Monaco, Courier New, Courier, monospace;
    font-size: 12px;
    background-color: #f9f9f9;
    border: 1px solid #D0D0D0;
    color: #002166;
    display: block;
    margin: 14px 0 14px 0;
    padding: 12px 10px 12px 10px;
}

#container {
    margin: 10px;
    border: 1px solid #D0D0D0;
    box-shadow: 0 0 8px #D0D0D0;
}

p {
    margin: 12px 15px 12px 15px;
}
</style>
    </head>
    <body>
        <div id="container">
            <h1>An Error Was Encountered</h1>
            <p>The URI you submitted has disallowed characters.</p>
        </div>
    </body>
</html>

Perhaps there is some kind of routing/DNS issue on the server?

Other API Example: The following request also does not work, returning a similar HTML page:

http://api.dol.gov/V1/FAQ/Topics

Based on the documentation, it seems like this should be a valid request (here, for example). Is it not? Also -- what is the relationship between these two separate APIs?

@MrSampson
Copy link

I would love to hear the response to this. I can find nothing that allows me to actually use the DOL API as described on the website.

@zshapleigh
Copy link

DATA.DOL use this
WebRequest request = WebRequest.Create(new Uri(uri));
request.Method = "GET";
request.Headers.Add("X-API-KEY", DOLApiKey);
request.ContentType = "application/json; charset=utf-8";
WebResponse response = request.GetResponse();
ret = new StreamReader(response.GetResponseStream()).ReadToEnd();
response.Close();

API.DOL use this
string Timestamp = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ");

                HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri);
                request.Method = "GET";
                request.AllowAutoRedirect = false;
                request.Accept = "application/json";// "*/*";
                request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";

                //string version of what gets built in the method: service_SendingRequest
                string requestUri = request.RequestUri.PathAndQuery;
                string signature = Hash(string.Format("{0}&Timestamp={1}&ApiKey={2}", requestUri, Timestamp, DOLApiKey), DOLSharedSecret);
                request.Headers["Authorization"] =
                    "Timestamp=" + Timestamp + "&"
                    + "ApiKey=" + DOLApiKey + "&"
                    + "Signature=" + signature;

                WebResponse authResponse = request.GetResponse();
                using (authResponse)
                {
                    using (var reader2 = new StreamReader(authResponse.GetResponseStream()))
                    {
                        ret = reader2.ReadToEnd();
                    }
                }

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants