Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Granule Content Type Error #22

Closed
cnizzardini opened this issue Nov 17, 2018 · 1 comment
Closed

Granule Content Type Error #22

cnizzardini opened this issue Nov 17, 2018 · 1 comment

Comments

@cnizzardini
Copy link

cnizzardini commented Nov 17, 2018

Running:
curl -X GET "https://api.govinfo.gov/packages/CREC-2018-01-04/granules/CREC-2018-01-04-pt1-PgD7-3/xml?api_key=DEMO_KEY" -H "accept: */*"

Response:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="http://origin.api.govinfo.gov/content/#contenterror">here</a>.</p>
</body></html>

The API explorer doesn't handle it well either https://api.govinfo.gov/docs/

@jonquandt
Copy link
Member

@cnizzardini - the first request is failing because CREC packages (and granules) do not have an XML representation of the content. The API is handling your request for an XML of the content and the server is returning our standard 404 for content that doesn't exist. You may want to add the -L switch to your curl request so that your request follows internal server redirects:

$ curl -L -X GET "https://api.govinfo.gov/packages/CREC-2018-01-04/granules/CREC-2018-01-04-pt1-PgD7-3/xml?api_key=DEMO_KEY" -H "accept: /"

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   235  100   235    0     0    203      0  0:00:01  0:00:01 --:--:--   209
100   182  100   182    0     0    147      0  0:00:01  0:00:01 --:--:--   147
100   123    0   123    0     0     89      0 --:--:--  0:00:01 --:--:--    89
{"timestamp":1542519554946,"status":404,"error":"Not Found","message":"No message available","path":"/govinfoapi/content/"}

Your options for content download for the granule you're looking for is available via the summary endpoint. e.g.:

curl -X GET "https://api.govinfo.gov/packages/CREC-2018-01-04/granules/CREC-2018-01-04-pt1-PgD7-3/summary?api_key=DEMO_KEY" -H "accept: /"

{"title":"Daily Digest/House of Representatives","collectionCode":"CREC","collectionName":"Congressional Record","category":"Proceedings of Congress and General Congressional Publications","dateIssued":"2018-01-04","detailsLink":"https://www.govinfo.gov/app/details/CREC-2018-01-04/CREC-2018-01-04-pt1-PgD7-3","granulesLink":"https://api.govinfo.gov/packages/CREC-2018-01-04/granules?offset=0&pageSize=100","packageId":"CREC-2018-01-04","packageLink":"https://api.govinfo.gov/packages/CREC-2018-01-04/summary","granuleId":"CREC-2018-01-04-pt1-PgD7-3","download":{"txtLink":"https://api.govinfo.gov/packages/CREC-2018-01-04/granules/CREC-2018-01-04-pt1-PgD7-3/htm","pdfLink":"https://api.govinfo.gov/packages/CREC-2018-01-04/granules/CREC-2018-01-04-pt1-PgD7-3/pdf","modsLink":"https://api.govinfo.gov/packages/CREC-2018-01-04/granules/CREC-2018-01-04-pt1-PgD7-3/mods","premisLink":"https://api.govinfo.gov/packages/CREC-2018-01-04/premis","zipLink":"https://api.govinfo.gov/packages/CREC-2018-01-04/zip"},"bookNumber":"1","granuleClass":"DAILYDIGEST","subGranuleClass":"DDHCHAMBER","granuleDate":"2018-01-04","pagePrefix":"D","lastModified":"2018-07-31T12:43:00Z"}

The download section in the summary shows:

"download": {
		"txtLink": "https://api.govinfo.gov/packages/CREC-2018-01-04/granules/CREC-2018-01-04-pt1-PgD7-3/htm",
		"pdfLink": "https://api.govinfo.gov/packages/CREC-2018-01-04/granules/CREC-2018-01-04-pt1-PgD7-3/pdf",
		"modsLink": "https://api.govinfo.gov/packages/CREC-2018-01-04/granules/CREC-2018-01-04-pt1-PgD7-3/mods",
		"premisLink": "https://api.govinfo.gov/packages/CREC-2018-01-04/premis",
		"zipLink": "https://api.govinfo.gov/packages/CREC-2018-01-04/zip"
	}

MODS and PREMIS present descriptive and preservation metadata about the content in xml format.

You'll see that performing a request for the htm rendition does return content as expected in curl:

$ curl -X GET "https://api.govinfo.gov/packages/CREC-2018-01-04/granules/CREC-2018-01-04-pt1-PgD7-3/htm?api_key=DEMO_KEY" -H "accept: /"

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   566  100   566    0     0    412      0  0:00:01  0:00:01 --:--:--   483
<html>
<head>
<title>Congressional Record, Volume 164 Issue 2 (Thursday, January 4, 2018)</title>
</head>
<body><pre>
[Congressional Record Volume 164, Number 2 (Thursday, January 4, 2018)]
[Daily Digest]
[Page D7]
From the Congressional Record Online through the Government Publishing Office [<a href="http://www.gpo.gov">www.gpo.gov</a>]





                        House of Representatives


Chamber Action
  The House was not in session today. The House is scheduled to meet in
a Pro Forma session at 12 noon on Friday, January 5, 2018.


</pre></body>
</html>

The API documentation page isn't really intended for curling in that manner -- since that /docs is a page that then fires off several requests to serve the swagger.json file in a (human) user-friendly manner

You could also just request the swagger.json directly via https://api.govinfo.gov/swagger.json

I hope that helps.

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

No branches or pull requests

2 participants