web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / JSON parsing error, ex...
Power Apps
Unanswered

JSON parsing error, expected number but got string when calling flow from Canvas app.

(0) ShareShare
ReportReport
Posted on by

I created the below command on a submit button of the app I am working on, in which, it calls a power automate to create a file on the document library, as well as patches a new item in sharepoint list. I am trying set the ID of the created file to a variable and update the sharepoint list with that variable in a column titled applogoID. However, I received the error of (JSON parsing error, expected number but got string). 

// Upload file to SharePoint
AppRegUploadFileToSharePoint.Run({
    file: {
        name: First(Attach_AppDisplayImage.Attachments).Name,
        contentBytes: First(Attach_AppDisplayImage.Attachments).Value
    }
});

// Set variable to capture the ID of the uploaded file
Set(varFileID, Value(AppRegUploadFileToSharePoint.Run({file:{name: First(Attach_AppDisplayImage.Attachments).Name, contentBytes: First(Attach_AppDisplayImage.Attachments).Value}}).id));

// Convert varFileID to a number
Set(varFileID, Value(varFileID));

// Patch App Details
Patch(
    'NPA-NIWC PAC Apps',
    Defaults('NPA-NIWC PAC Apps'),
    AppReg_Form.Updates,
    {AppLogoID: Value(varFileID)
}
);
NotificationType.Success;
Navigate(HM_Screen, ScreenTransition.Fade)

 

Categories:
  • DJ_Jamba Profile Picture
    2,837 Moderator on at

    Hi @Johnny23 

    Could you throw a button on the screen somewhere and add this to the OnSelect property:

    Set(tempVar, varFileID + 1)

     

    Then:

    1. Check if it there's an error when you hit the button 

    2. Look for tempVar in Global Variables and check what the number is

    DJ_Jamba_0-1711666864923.png

     

     

  • CU10121450-0 Profile Picture
    on at

    Hi, 

     

    The number for the tempVar variable is 1.

  • CU10121450-0 Profile Picture
    on at

    also there was no error when I clicked the button @DJ_Jamba 

  • DJ_Jamba Profile Picture
    2,837 Moderator on at

    OK - The problem is not there then.

    Where and when do you see this message "JSON parsing error, expected number but got string"?

    And is it the full message?

    Are you able to supply screenshots of where the error occurred without revealing any sensitive data.

    It's tough driving in the dark 😂

  • CU10121450-0 Profile Picture
    on at

    Johnny23_0-1711719056664.pngJohnny23_2-1711719331499.png

    Johnny23_3-1711719391016.pngJohnny23_4-1711719418170.png

     

     

  • CU10121450-0 Profile Picture
    on at

    When I click the submit button shown above the error appears. 

  • DJ_Jamba Profile Picture
    2,837 Moderator on at

    Have a look in your form and check that any fields that should contain numbers, are in fact numbers and not text.

  • CU10121450-0 Profile Picture
    on at

    Johnny23_0-1711720154213.png

    All the fields above are the correct types. I do not place applogoid as part of the form, but rather trying to patch that field with the ID from the document that is uploaded to the document library. 

     

  • DJ_Jamba Profile Picture
    2,837 Moderator on at

    Could you try the following:

     

    Add the AppLogoId field to your form and hide it.

    In the Update property of the card, enter varFileID

     

    Comment out the top section of your code as highlighted in the first box.

    DJ_Jamba_0-1711720839904.png


    Hard code varFileID for now e.g.

     

     

    Set( varFileID, 8 )

     

     

     

     

    Then change your Patch to only use your form updates e.g.

     

     

     

    Patch(
     Datasource,
     Defaults(Datasource),
     FormName.Updates
    )

     

     

     

  • DJ_Jamba Profile Picture
    2,837 Moderator on at

    For some reason it does not complete the Set code, it's supposed to be:
    Set( varFileID, 8 )

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 248 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 192 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 135

Last 30 days Overall leaderboard