Skip to content

Commit

Permalink
Test add property 'User-Agent' to get request in 'findDataPids' method
Browse files Browse the repository at this point in the history
  • Loading branch information
doulikecookiedough committed Oct 25, 2024
1 parent 297293b commit 1426b23
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/java/edu/ucsb/nceas/mdqengine/MDQEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,13 @@ public ArrayList<String> findDataPids(NodeReference nodeId, String identifier) t
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setRequestProperty("Accept", "application/xml");
connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36");
if (dataOneAuthToken != null) {
connection.setRequestProperty("Authorization", "Bearer " + dataOneAuthToken);
}

if (connection.getResponseCode() != 200) {
throw new RuntimeException("Failed : HTTP error code : " + connection.getResponseCode());
throw new RuntimeException("Failed : HTTP error code : " + connection.getResponseCode() + connection.getResponseMessage());
}

InputStream xml = connection.getInputStream();
Expand Down

0 comments on commit 1426b23

Please sign in to comment.