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

MktngAtmtnCnsltnt 1 Reputation point
2021-03-02T13:27:50.86+00:00

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,740 questions
Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
2,829 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,829 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Mike Urnun 9,651 Reputation points Microsoft Employee
    2021-03-09T02:04:06.25+00:00

    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. Suryawanshi, Rakesh 1 Reputation point
    2021-03-11T11:51:28.827+00:00

    use Newtonsoft json

    JsonSerializer _jsonWriter = new JsonSerializer {
    NullValueHandling = NullValueHandling.Ignore
    };

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

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

    https://stackoverflow.com/questions/6507889/how-to-ignore-a-property-in-class-if-null-using-json-net

    0 comments No comments