NullReferenceException at achievements

Aug 23, 2011 at 4:53 PM
Edited Aug 23, 2011 at 4:54 PM


First of all I like to thank you for the library and say that I'm pretty new  working with APIs. I have a question regarding a nullreference exception.

 using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.Mvc;using WOWSharp.Community;

using WOWSharp.Community.ObjectModel;



ApiClient api = new ApiClient(Region.EU);

DateTime[]test = api.GetCharacter(server, charname).Achievements.AchievmentsCompletedDatesUtc;

server and charname are two strings

I take it that the function should return an array of dates when achievements were completed. 
Does it take too long time for blizzard to respond or is it something I'm doing wrong?

Thanks in advance! 

Aug 24, 2011 at 2:26 AM


The GetCharacter method has 3 overloads. The one you called will only return the basic character information and will not return any of the optional character information (like achievements, guild info, pvp info, equipment, etc).

If you want to get all fields

api.GetCharacter(server, charname, true)

If you want to get achievements only

api.GetCharacter(server, charname, CharacterField.Achievements)

The CharacterField enum has Flags attribute so you can get items, quests completed and achievements only like that

api.GetCharacter(server, charname, CharacterField.Achievements | CharacterField.Items | CharacterField.Quests);
Aug 24, 2011 at 10:02 AM

Thanks a lot for the fast anwser, it's working now :)