Eearslya.6309:

I don’t know much about Python, but one thing that I notice right away is that you’re trying to use both the access_token parameter and a header. You only need one or the other; the page may be failing to load because of this.

Dash.8027:

I don’t know much about Python, but one thing that I notice right away is that you’re trying to use both the access_token parameter and a header. You only need one or the other; the page may be failing to load because of this.

If I comment out line lines 10 and 11, it returns the Account Names and Guild IDs, I think the problem is with the array and being challenged for the Guild ID to Guild Name conversation. I have no idea how to make it parse the array and return each guild in another method.

I’m looking for :

Player.1234 – Guild 1 – Guild 2 – Guild 3 – Guild 4 – Guild 5
Player.3456 – Guild 1 – Guild 2 – Guild 3 – Guild 4 – Guild 5
ect.

Right now I’m getting by commenting out lines 10/11 :

Player.1234 [u’5CAD86D7-7A62-4A31-970B-4DFCD0032D27’, u’9BC2F0EE-4D8C-E311-863C-E4115BDF481D’]
Ect.

zeeZ.5713:

You’re doing


        accountjson = requests.get('https://api.guildwars2.com/v2/account?access_token=', headers = head) 
        accountdata = accountjson.json()
        accountname = accountdata['name']

but for guilds you’re doing


        guilddata = requests.get('https://api.guildwars2.com/v1/guild_details.json?guild_id='+ str(guildid)) 
        guildname = guilddata['guild_name']

which is why you’re getting


Traceback (most recent call last):
File “D:\guild.py”, line 11, in <module>
guildname = guilddata[‘guild_name’] #account guild information
TypeError: ‘Response’ object has no attribute ‘getitem’

Dash.8027:


guildjson = requests.get('https://api.guildwars2.com/v1/guild_details.json?guild_id='+ str(guildid)) 
guilddata = guildjson.json()
guildname = guilddata['guild_name'] 

Traceback (most recent call last):
File “D:/guild.py”, line 13, in <module>
guildname = guilddata[‘guild_name’] #account guild information
KeyError: ‘guild_name’

This returns a KeyError. :/ At this point I don’t know what to do to fix it.

zeeZ.5713:

You look at the data to see why it doesn’t contain the key it should contain, figure out if you a) did something wrong and fix it, or b) data without that key can be a valid result and determine how you want to handle those cases.

If you don’t know what’s going on, add more logging. And then some more. Up to the point where you might as well just step through the debugger. And then do that.

Dash.8027:

Ok, so I found that if I remove the first 3 characters from the returned string, it’ll give me the name of the first guild in the list. I however need to remove the the first 3 from each guildid and have no idea how to go about this.


guildjson = requests.get('https://api.guildwars2.com/v1/guild_details.json?guild_id='+ str(guildid)[3:])

Am I doing this wrong having the .get run the entire string at once?
I’m not the best of coders obviously; any help would be greatly appreciated. I’ve gone all over google and can’t find an answer I understand.

Dash.8027:

And I accidently my main post. Reworking my script; almost entirely. TY for the help thus far.