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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Flow is removing dupli...
Power Automate
Unanswered

Flow is removing duplicate objects in body JSON in custom connector

(0) ShareShare
ReportReport
Posted on by 166

Building a custom connector to another web app that we use. Basically, the JSON looks like this according to their documentation:

{
 "workspace": {
 "title": "string",
 "creator_role": "string",
 "custom_fields": [
 {
 "custom_field_id": 0,
 "value": "string"
 }
] } }

However, there are multiple "custom_fields", so it should be more like this:

{
 "workspace": {
 "title": "string",
 "creator_role": "string",
 "custom_fields": [
 {
 "custom_field_id": 0,
 "value": "string"
 },
 {
 "custom_field_id": 0,
 "value": "string"
 },
 {
 "custom_field_id": 0,
 "value": "string"
 }
 ]
 }
}

And would eventually be something like this:

{
 "workspace": {
 "title": "Test Title",
 "creator_role": "admin",
 "custom_fields": [
 {
 "custom_field_id": 123,
 "value": "Test Custom Field 1"
 },
 {
 "custom_field_id": 456,
 "value": "Test Custom Field 2"
 },
 {
 "custom_field_id": 789,
 "value": "Test Custom Field 3"
 }
 ]
 }
}

However when I drop in the second code snippet, it removes the duplicate "custom_fields". How do I prevent this?

Categories:
I have the same question (0)
  • yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    Hi @ishraqiyun77 

     

    You should be defining the schema for JSON appropriately for that. Define the "Custom_Fields" as an array. You might want to refer to the below JSON schema for this:

    {
     "type": "object",
     "properties": {
     "workspace": {
     "type": "object",
     "properties": {
     "title": {
     "type": "string"
     },
     "creator_role": {
     "type": "string"
     },
     "custom_fields": {
     "type": "array",
     "items": {
     "type": "object",
     "properties": {
     "custom_field_id": {
     "type": "integer"
     },
     "value": {
     "type": "string"
     }
     }
     }
     }
     }
     }
     }
    }

    Hope this Helps!

    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

  • ishraqiyun77 Profile Picture
    166 on at

    That helps me out a ton! Would you be able to point me in the direction of the Microsoft resource of how to properly format JSON for connectors? I was under the wrong impression definitely of what it was requesting.

  • yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    Hi @ishraqiyun77 

     

    I would suggest you have a look at this blog:

    https://blog.mastykarz.nl/what-know-building-microsoft-flow-custom-connectors/

     

    The entire process of creating custom connectors and the JSON formatting has been explained well here. 

     

    edit: you can use the JSON Parse data operation action to get the format for any JSON resposne. Just click "Use sample payload to generaet Schema" and add a sample output here. 

    ssdc.png

     

     

    Hope this Helps!

  • ishraqiyun77 Profile Picture
    166 on at

    Ok, perhaps I'm doing something wrong...

    Just using your snippet below results in the following:

    Capture.PNGCapture1.PNG

    It is really non-descript what parameters these correspond with.

  • yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    Hi @ishraqiyun77 

     

    Can you please share what you have passed in the body part over there? I am guessing this is happening because you have passed the same key for all the body items.

  • ishraqiyun77 Profile Picture
    166 on at

    Hi @yashag2255 

    This is the JSON I am passing in:

    {
     "type": "object",
     "properties": {
     "workspace": {
     "type": "object",
     "properties": {
     "title": {
     "type": "string"
     },
     "creator_role": {
     "type": "string"
     },
     "custom_fields": {
     "type": "array",
     "items": {
     "type": "object",
     "properties": {
     "custom_field_id": {
     "type": "integer"
     },
     "value": {
     "type": "string"
     }
     }
     }
     }
     }
     }
     }
    }
  • ishraqiyun77 Profile Picture
    166 on at

    Also, even taking the JSON snippet from here:

    https://blog.mastykarz.nl/what-know-building-microsoft-flow-custom-connectors/

    Results in pretty much the same behavior:

    {
     "properties": {
     "file": {
     "title": "File contents",
     "type": "string",
     "format": "binary"
     }
     }
    }

    image.png

    It seems like it should be populating these fields for one of the properties, but that isn't happening.

    Capture.PNG

    And to point out, when I do something like this:

    {
     "workspace": {
     "title": "string",
     "creator_role": "string",
     "custom_fields": [
     {
     "custom_field_id": 0,
     "value": "string"
     }
    ] } }

     This works as expected. It just removes the duplicate custom_field_id and value which I need in there. So a bit confused on how to approach this.

    image.png

  • ishraqiyun77 Profile Picture
    166 on at

    Also, another clarification, I am doing this all by adding an Action and then under Request, I am clicking the "+ Import from sample". Perhaps there is a different way I should be doing this, but that much is not clear to me.

  • yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    Hi @ishraqiyun77 

     

    Please see the screenhots below:MicrosoftTeams-image (151).png

     

    MicrosoftTeams-image (152).png

     

    I did a test on my end and you need to pass below schema while creating your request in custom connector.
    {
      "workspace": {
        "title": "Test Title",
        "creator_role": "admin",
        "custom_fields": [
          {
            "custom_field_id": 123,
            "value": "Test Custom Field 1"
          },
          {
            "custom_field_id": 456,
            "value": "Test Custom Field 2"
          },
          {
            "custom_field_id": 789,
            "value": "Test Custom Field 3"
          }
        ]
      }
    }
    It will create 4 parameters each for title,creator's role,  custom_field_id and value. I tried to pass custom_fields as an array while testing out this and it returned me the correct response.
     
    Hope this Helps!
     
    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
  • ishraqiyun77 Profile Picture
    166 on at

    Ok, again, it seems like I am missing something. This is what I get when I "+ Import from sample" using that snippet:

    Capture.PNG

    It removes the duplicates. I need to send like 25 custom_field_id and value objects in that array.

     

    This is what the Test Operations looks like. Again, they are not there for me to pass values into.

    Capture1.PNG

    Yeah, I can modify the body and manually add them back in before the test, but I don't know how this helps me when finalizing the connector and actually using it in a flow. Those additional 25 or so custom_fields will likely not be available.

    Capture2.PNG

    So I am missing something...

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 Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard