Not supported exception when getting AllFriends

0 votes

Hi,

Im trying to get all the friends that my user have on the buddy service, this is the code I'm using in Unity:

//Inside a Coroutine

bool gettingBuddiesFromServer = true;

IList<Buddy> buddies = null;

try

{

   buddies = buddyService.GetAllFriends(m_pPlayerData.m_strUniqueID);

}

catch (App42Exception e)

{

  Debug.Log("Exception On Getting all Friends: "+e);

  Debug.Log("Error Codes:App["+e.GetAppErrorCode()+"] http["+e.GetHttpErrorCode()+"]   Message["+e.GetMessage()+"]");

  gettingBuddiesFromServer = false;

}

while(buddies == null && gettingBuddiesFromServer)

{

  Debug.Log("Waiting for all buddies of this player");

  yield return 0;

}

if(buddies.Count > 0)

{
//do something with the buddies
}

but every time I got the next message:

NotSupportedException: https://api.shephertz.com/cloud/1.0/buddy/friends/0f607264fc6318a92b9e13c65db7cd3c?

  at System.Net.WebRequest.GetCreator (System.String prefix) [0x00000] in <filename unknown>:0 

  at System.Net.WebRequest.Create (System.Uri requestUri) [0x00000] in <filename unknown>:0 

  at System.Net.WebRequest.Create (System.String requestUriString) [0x00000] in <filename unknown>:0 

  at com.shephertz.app42.paas.sdk.csharp.connection.RESTConnectorAsync.ExecuteGet (System.String url, System.Collections.Generic.Dictionary`2 paramsDics, System.Collections.Generic.Dictionary`2 headerParams) [0x00000] in <filename unknown>:0 

  at com.shephertz.app42.paas.sdk.csharp.buddy.BuddyService.GetAllFriends (System.String userName) [0x00000] in <filename unknown>:0 

  at SocialManager+<GetAlreadyPlayingFriendsProcedure>c__Iterator56.MoveNext () [0x00000] in <filename unknown>:0 

 

What is it wrong?

 

asked Jun 4, 2014 in App42 Cloud API-BaaS by chrystiansilva (33 points)

1 Answer

0 votes

Always use unity methods with callback, as the non-callback methods are not unity safe.

So, use this method as described in the documentation,

http://api.shephertz.com/app42-docs/buddy-management-service/?sdk=unity#get_all_friends

this'll resolve your error.

answered Jun 5, 2014 by Akshay.Mishra (179 points)
edited Jun 5, 2014 by Akshay.Mishra
Hi, I've change the code to the Unity Safe Version, now I'm using this:

buddyService.GetAllFriends(m_pPlayerData.m_strUPID,new GetAllFriendsFromServerCallBack());

and this:

public class GetAllFriendsFromServerCallBack : App42CallBack  
    {  
        public void OnSuccess(object response)  
        {  
            IList<Buddy> buddies = (List<Buddy>) response;       
            if(buddies.Count > 0)
            {
                for(int i = 0; i < buddies.Count;i++)
                {
                    Debug.Log("Friend["+buddies[i].GetBuddyName()+"] In server Founded");
//load this friend data                    SocialManager.GetInstance().storageService.FindDocumentByKeyValue(SocialManager.GetInstance().dbName,SocialManager.GetInstance().collectionName,"UPID",buddies[i].GetBuddyName(),new  GetFriendDataOnServerAndCreate());
                }
            }
            else
            {
                //something is wrong
            }
        }  
      
        public void OnException(Exception e)  
        {  
            Debug.Log("Exception On Getting all Friends: "+e);
            App42Exception ex = (App42Exception)e;
            Debug.Log("Error Codes:App["+ex.GetAppErrorCode()+"] http["+ex.GetHttpErrorCode()+"] Message["+ex.GetMessage()+"]");
       
        }  
    }  


but get this error:

Exception On Getting all Friends: com.shephertz.app42.paas.sdk.csharp.App42Exception: 404 not found
Error Codes:App[0] http[0] Message[]

What could it be?
I checked this method this works fine, for more details put App42Log.SetDebug(true);  in your OnStart method, and share the logs printed in your editor's console.
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...