I need to build the Body dynamically within the HTTP Request to use the PATCH method.

MktngAtmtnCnsltnt 1 Reputation point

I need to build the Body dynamically within the HTTP Request to use the PATCH method. Does anyone have any suggestions? For example. If "var1" or "var2" is equal to null. This does not enter the construction of the Body. The goal is to update only the fields that are informed of the values ​​to update. ![73377-2021-03-02-125121.jpg][1] [1]: /api/attachments/73377-2021-03-02-125121.jpg?platform=QnA

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
1,230 questions
Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
2,100 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
4,908 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. MikeUrnun 5,756 Reputation points

    Hi @MktngAtmtnCnsltnt ,

    Welcome to MS QnA, and thank you for posting here!

    I'd like to suggest using Conditional to check against null values and build the request dynamically according to your requirements: Create conditional statements that control workflow actions in Azure Logic Apps

    Another approach is to execute the same logic in Javascript: Add and run code snippets by using inline code in Azure Logic Apps

    Lastly, here's an example of how it can be done: https://learn.microsoft.com/answers/answers/46005/view.html

  2. Rakesh Suryawanshi 1 Reputation point

    use Newtonsoft json

    JsonSerializer _jsonWriter = new JsonSerializer {
    NullValueHandling = NullValueHandling.Ignore

    or you can use like:
    // or
    [JsonProperty("property_name", NullValueHandling=NullValueHandling.Ignore)]

    // or for all properties in a class
    [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)]


    0 comments No comments