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 :
Dynamics 365 Community / Blogs / Customizing Dynamics 365 / Easily make HTTP requests (...

Easily make HTTP requests (PATCH/DELETE/POST) in Dynamics CRM using the browser console

Pedro Esteves Profile Picture Pedro Esteves

The purpose of this community post is to show you how you can easily make HTTP requests to Dynamics CRM through the browser without using third-party tools.

A PATCH, DELETE and POST request will be exemplified.

PATCH request:

To illustrate the PATCH request, the documentation below will be used, the description of a cloud flow will be updated.

Manage flows with the Power Automate Web API - Power Automate | Microsoft Learn

pastedimage1672687258361v1.png

The first thing that needs to be done is to find the workflowid, which identifies the workflow that will have its description updated.

pastedimage1672687295233v2.png

We can fetch the workflowidunique: b047b268-0fe1-4fd0-a732-64bdf3ab0e07 from the make.powerapps.com url and write the Web API query below to obtain the workflowid.r

org_url/api/data/v9.2/workflows?$filter=workflowidunique%20eq%2028c0d66e-8d73-4f75-9f98-27410375d8da

pastedimage1672687368627v3.png

Now that we have the workflowid, to make the PATCH request to change the description of the Power Automate flow we just to need to have Dynamics CRM on the current tab, open a DevTools console using F12 and execute the following request inside it:

 

fetch(window.origin + "/api/data/v9.2/workflows(2019fb81-098a-ed11-81ad-0022489fdddf)",{

method: "PATCH",

headers: {'Content-Type': 'application/json'},

body: JSON.stringify({'description': "new description"})

}); 

  1. Notice that on the request url we have included the workflowid.
  2. The method is "PATCH".
  3. The description has been updated to "new description".

Before:

pastedimage1672687403480v4.png

Pasting the request on Dev Tools:

pastedimage1672687448962v5.png

After the request has been executed we can see that the description has changed successfully:

pastedimage1672687483762v6.png

DELETE Request:

Cloud flow deletion can be also accomplished using a similar request.

The changes needed include:

  • Changing the request from PATCH to DELETE.
  • Remove body from the request.

 

This is what the new request will look like:

fetch(window.origin + "/api/data/v9.2/workflows(2019fb81-098a-ed11-81ad-0022489fdddf)",{

method: "DELETE",

headers: {'Content-Type': 'application/json'},

});

Before:

pastedimage1672687515522v7.png

Pasting the request on DevTools:

pastedimage1672687543563v8.png

As we can see on the screenshot below, the flow has been successfully deleted.

pastedimage1672687584761v9.png

POST request:

Lastly, a POST request can also be done in similar fashion, following the documentation below, here is how you can create an account:

Create a table row using the Web API (Microsoft Dataverse) - Power Apps | Microsoft Learn

8233.pastedimage1672732136922v1.png

fetch(window.origin + "/api/data/v9.2/accounts",{

method: "POST",

headers: {'Content-Type': 'application/json'},

body: JSON.stringify({

'name': "Sample Account",

'description': "This is a sample account"

})

}); 

Before:

pastedimage1672733149281v2.png

After: As it can be seen the account was created.

pastedimage1672733231308v3.png

Hope this community post was a pleasant reading.

Now you are familiar with a simple way on how to do HTTP requests without using third-party tools.

Thanks for reading!

Comments

*This post is locked for comments