question

kerryurkraft avatar image
kerryurkraft asked

No function was found to execute

What I'm trying to do is create a new character in playfab ! I created a cloud script in Azure called CreateCharacter and if i calle it directly by code it works fine ! Then i create a Cloud script in Playfab called CreateCharacter, type HTTP and connected with the link to the Azure one.

This is the Azure Script :

 module.exports = async function (context, req) {
     // Checks if characterName and PlayFabId parameters are present in the request
     if ((req.query.characterName || (req.body && req.body.characterName)) && (req.query.playFabId || (req.body && req.body.playFabId))) {
         // Extract the characterName and PlayFabId values ​​from the request
         const characterName = req.query.characterName || (req.body && req.body.characterName);
         const playFabId = req.query.playFabId || (req.body && req.body.playFabId);
    
         // After successfully creating the character, return a successful response
         context.res = {
             status: 200,
             body: { success: `Personaggio ${characterName} successfully created for PlayFabId ${playFabId}.` }
         };
     } else {
         // If the characterName and playFabId parameters are not provided, return an error response
         context.res = {
             status: 400,
             body: { error: 'Parameters characterName e playFabId missing. Be sure to provide a character name and your PlayFabId.' }
         };
     }
 };

Now that's my client side code :

 createCharacterButton.GetComponent<Button>().onClick.AddListener(() => CreateNewCharacter(characterName, playFabId));
    
 private void CreateNewCharacter(string characterName, string playFabId)
     {
         if (PlayFabClientAPI.IsClientLoggedIn())
         {
             CreateCharacterParameters functionParameters = new CreateCharacterParameters
             {
                 characterName = nomepersonaggio,
                 playFabId = MyPlayFabID
 // these parameters work well so far
             };
    
             PlayFabClientAPI.ExecuteCloudScript(new ExecuteCloudScriptRequest()
                
             {
                 FunctionName = "CreateCharacter", 
                 FunctionParameter = functionParameters,
             },
    
                OnCharacterCreation, OnCharacterCreationError);
         }
            
         else
         {
             // manage unauthenticated player
             Debug.LogError("unauthenticated player.");
         }
      }
    
    
 private void OnCharacterCreation(ExecuteCloudScriptResult result)
     {
         if (result.Error != null)
         {
             Debug.LogError("Error character creation " + result.Error.Message);
         }

the error falls in the first if (if (result.Error != null)) No function named CreateCharacter was found to execute. Actually i'm using only using PlayFab.ClientModels; but no using PlayFab.CloudScriptModels; Could this be the reason for the error?

CloudScriptCharacters
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Infer Wang avatar image
Infer Wang answered

Yes, you ought to use ExecuteFunction instead of ExecuteCloudScript.

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

kerryurkraft avatar image kerryurkraft commented ·

Before using ExecuteCloudScript. I used ExecuteFunction to but the problem is the same... after several changes the real problem seems to be passing FunctionParameter . which are not passed correctly to the cloud script. Now I know that FunctionParamet wants an Object type, I tried several ways, passing individual strings, passing a dictionary, and also passing a deserialized json class but nothing...

0 Likes 0 ·
Infer Wang avatar image Infer Wang kerryurkraft commented ·

Yes, you may create your own class and define an object type. I’m glad you have figured out this issue. And if you have further questions, feel free to tell us.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.