system.net.httpGet returning blank lines

I am having a weird response to one of my API calls, all my other calls work with my API key so I know it isn’t an authentication problem, but whenever I run my script, it outputs a blank line. No error or anything, just nothing.

# Global Imports
import json
import time
from datetime import datetime
# Global Props
apiKey = system.db.runNamedQuery("api/getApiKey", {})
apiRoot = "https://www.bungie.net/Platform"
header = {"X-API-Key":apiKey}
logger = system.util.getLogger("bungieAPI")

def getPostGameCarnageReport(activityId,destinyMembershipId):
	apiPath = apiRoot + "/Destiny2/Stats/PostGameCarnageReport/" + str(activityId) + "/"
	apiCall = system.net.httpGet(apiPath,headerValues=header)
	print apiCall
	logger.info("getPostGameCarnageReport Completed")

getPostGameCarnageReport(10425543145,4611686018432886684)

Here is what I am getting in my script console.

By default, system.net.httpGet should throw an exception if it receives a non-200 response… Is it possible that the request is succeeding but there is simply nothing in the response body?

You might try using something like curl or Postman to issue the request and inspect the response. Additionally, if you need more granular control, you might also look toward our system.net.httpClient interfaces for making web requests.

Again, not sure about the API in question here, but I also notice you’re not actually using the destinyMembershipId in your request path. Intentional?

Sorry should have clarified, I have tried in Postman and it works.


on the destinyMembershipId my plan is to use it later in the script once I have the response back to parse through the json.

I wonder if supplying useCaches=False to the call would change anything?

The same result, unfortunately.

I don’t know if or why it would change anything, but since you’re on 8.1 you should be using system.net.httpClient instead.

For replication, I don’t mind sharing my API key via DM; I just didn’t want to post publically.


At least it is a different issue.

Yeah, you’re getting redirected. Create the client with redirect_policy="ALWAYS".

Also you’ll probably want to call .text or .json on the response object you get, once it has content.

That did it!
So with httpClient, are the other methods depreciated now?

Not full on deprecated, but system.net.httpClient is a significantly better implementation in all regards. If you are writing new code you should use it.

I see, thank you for your help @Kevin.Herron and @kcollins1

OK, I’m curious if you don’t mind sharing, what’s the end goal for pulling in data from Destiny servers? Trying to build some performance dashboards? Just wasn’t expecting to see Bungie servers in Ignition haha.

3 Likes

More or less, over the years there’s been a couple of different sites that have tried to build a score aggregation system grouped by clans where you can compete in various in-game events for the highest aggregate score, unfortunately, they all get shut down usually for the cost of the services or the time it takes to maintain, so I am just trying my hand at bringing that back, using Ignition Maker.
https://d2clanwars.com/data/perspective/client/Destiny-2-Clan-Wars/standings

4 Likes