May 12 2023 06:48 AM
May 12 2023 11:44 AM
You can exclude the field pilot in the json body, if you are not assigning any value.
To conditionally include a JSON body field named 'pilot' in a Graph API request from Microsoft Flow, you can use the "Compose" action along with an expression to check if the field contains data. Here's an example:
1. Add a "Compose" action before the "HTTP" action in your Microsoft Flow.
2. In the "Compose" action, use an expression to check if the field contains data. For example, you can use the following expression:
if(empty(outputs('pilot')), null, outputs('pilot'))
This expression checks if the 'pilot' output is empty. If it is empty, it returns `null`. Otherwise, it returns the value of the 'pilot' output.
3. Use the output of the "Compose" action in the JSON body of the "HTTP" action. In the "Body" field of the "HTTP" action, reference the output of the "Compose" action using the dynamic content selector (the expression should be something like `@{outputs('Compose')}`).
By using this approach, the 'pilot' field will only be included in the JSON body if it has any data. If it is empty, the field will not be included in the request.
By using conditional expressions in the "Compose" action, you can dynamically construct the JSON body based on the presence or absence of data in your fields.
If I have answered your question, please mark your post as Solved If you like my response, please give it a like |
May 15 2023 02:00 AM
@Deleted I do not want to exclude the field, I'm specifically trying to set it to be blank and override the default value!
May 15 2023 04:37 AM
@Norro1475 Try passing null value instead of "" to your choice field and see if it works for you.
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
May 15 2023 07:27 AM - edited May 15 2023 07:48 AM
No, null no longer works either.
On further investigation it appears to be enforcing the predetermined choices where previously it was not. This prevents it being emptied by either means!
Huge bug IMHO. Restrictions should apply if it is filled, not prevent it being left/reset unfilled, there is another option for that.
option 2 is supposed to allow nulls, but is now totally ignored if tickbox 1 isn't chosen :(