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

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Dataverse Web API Patch
Power Apps
Unanswered

Dataverse Web API Patch

(0) ShareShare
ReportReport
Posted on by

 

$apiCallParams =
@{
 URI = "$($dataverseEnvUrl)/api/data/v9.2/parties(a59ca5ea-8f3a-ee11-a81c-0022489a9f93)"

 Headers = @{
 "Authorization" = "$($authResponse.token_type) $($authResponse.access_token)"
 "Content-Type" = "application/json"
 "OData-MaxVersion"="4.0"
 "OData-Version"="4.0"
 "If-Match"='*'
 }

 Method = 'PATCH'
}

$body = 
@{
 'new_number'=11
}

# Call the Dataverse WebAPI
$apiCallRequest = Invoke-RestMethod @apiCallParams -Body $body -ErrorAction Stop
$apiCallResponse = $apiCallRequest 

 

 

Running this script to update a record in Dataverse.

But getting Error identified in Payload error

 

Jorge_1-1692262559473.png

 

new_number is just a text field.

 

Do you see any error here?

Thanks

I have the same question (0)
  • Parvez Ghumra Profile Picture
    1,579 Moderator on at
    Re: Dataverse Web API Patch

    @Jorge If you're running this code from a PowerShell script, you might want to consider using the https://github.com/seanmcne/Microsoft.Xrm.Data.PowerShell PowerShell module rather than invoking the WebAPI directly. Your code will be much easier to read, maintain and support.

  • codepic Profile Picture
    7 on at
    Re: Dataverse Web API Patch

    Only problem is, that Microsoft.Xrm.Data.PowerShell doesn't support .NET Core which is a requirement if you wish to run the scripts on Linux/MacOs

  • Parvez Ghumra Profile Picture
    1,579 Moderator on at
    Re: Dataverse Web API Patch

    @codepic That's true. An alternative module which I've discovered since my reply above is https://github.com/rnwood/Rnwood.Dataverse.Data.PowerShell that will run on non-Windows machines

  • codepic Profile Picture
    7 on at
    Re: Dataverse Web API Patch

    I don't see a benefit in adding a 3rd party module maintained by a single person to our solution when I know that this person will grow tired of maintaining the module as soon as an official one becomes available. In other words, I prefer communicating via API directly.

     

    Whatever complexity that brings, can be abstracted away by having your own PowerShell module with custom functions within the project structure. Then you can simply add `using module .\path\to\module` on the top of your script and your code will become something like this:

    task Check {
     Get-CoChecks | ForEach-Object {
     $check = $_
     $rules = Get-CoRules $check._check_value
     $rules | ForEach-Object {
     $rule = $_
     $outcome = Test-CloudResource -Check $check -Rule $rule
    
     switch ($outcome) {
     'Continue' {
     return
     }
     'Stop' {
     break
     }
     Default {
     Set-Outcome `
     -Check $check `
     -Rule $rule `
     -Outcome $outcome
     }
     }
     }
     }
    }


    This way the adoption of PowerShell in our organization becomes much more approachable to others. Those who need and want to delve deeper into what each of those custom functions do, can do so by CTRL-clicking a function name. But for the rest, they can stick to reading the high-level code which has neither 3rd party module nor an OData call in it. Those who DO delve deeper, are already familiarized themselves with OData APIs. For them, having a direct API call is much more understandable than trying to figure out what some 3rd party module does under the hood.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 836 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 231 Super User 2025 Season 2

Last 30 days Overall leaderboard