cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AlfonsoLans
Frequent Visitor

Problems with Flow Expected Object but got Array

Hi Team hope you all are doing great I need help with my flow, I am getting this message: 

 

[ { "message": "Invalid type. Expected Object but got Array.", "lineNumber": 0, "linePosition": 0, "path": "cfdi:Comprobante.cfdi:Conceptos.cfdi:Concepto", "schemaId": "#/properties/cfdi:Comprobante/properties/cfdi:Conceptos/properties/cfdi:Concepto", "errorType": "type", "childErrors": [] } ]

 

 

8 REPLIES 8
DamoBird365
Microsoft
Microsoft

Hi @AlfonsoLans 

 

If means that the flow action is expecting an object {} but you have provided it with an array [].  What is it you are trying to do?  Can you share details or does this help?

 

Damien

 

I am trying to get an XML then parse the json to populate a sharepoint list, But I am getting problems with the ones more that 1 line 

 

Content

{
  "?xml": {
    "@version""1.0",
    "@encoding""UTF-8"
  },
  "cfdi:Comprobante": {
    "@Version""3.3",
    "@Serie""A",
    "@Folio""4542",
    "@Fecha""2021-12-16T10:13:43",
    "@Sello""e7wKQ2lrEoDvt/8PmCSZuyQ/ntsOhFV7R6onzUR/opcQaA6zsvJdmwQE0fojcaO8vizvQxPaCfn/n3KoSlRD00VkCBNT4FcWJQpc7V78OCmsnvO/BXyKSzTb2hzMydnLH70XSocTJK/5afYKd1ESIgqMv04upVHiqvR+CrIJdzWpQQmCuf/Gr3TlYNEhBaksDL+mF2FXUxD5XBXjXmcW5UskB6vgOejH4ZDuYQpcKwYvi1y6xyaCYYU9qW0Z32VIzE47kFnV3hTUYavGL9L3kVPIWzSgxPDEqdiO0cKdNRIHevGXfPkofyAVkQRlB2r3BOMucfpEDDVT/JAjaQnkBw==",
    "@FormaPago""99",
    "@NoCertificado""00001000000413533074",
    "@Certificado""MIIGBTCCA+2gAwIBAgIUMDAwMDEwMDAwMDA0MTM1MzMwNzQwDQYJKoZIhvcNAQELBQAwggGyMTgwNgYDVQQDDC9BLkMuIGRlbCBTZXJ2aWNpbyBkZSBBZG1pbmlzdHJhY2nDs24gVHJpYnV0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beg3FBvP87ski5nSR6tzIo06Bh92dtBD9jJDBGvxBrvRAGeulSCgAOpRWbiI7YMyet2uOsBdchzriu/k3nvWsyt2nMwao8RkCAwEAAaMdMBswDAYDVR0TAQH/BAIwADALBgNVHQ8EBAMCBsAwDQYJKoZIhvcNAQELBQADggIBAJFx5FAivDXVUR//kkCh2gTHQp00qS1aFTNP+6Vi4BtSVnKkdLO231UKpCbQhPsjRbkz2PakjBAMxf4gAfWCfrKhLFcgu4d8fYGJGeRfNiKhxpRbkCIGYTB8lSJqFYXTUf4MzPl+8hDwKVWRTxZcNgwB7/b7jXoMkpAu7ChVnVoOcqH8Uo5WqEjHIqtUeS47wZCIstS83+jTTf3UOWSL++x3r/+tn1v5g/lr8sbNmZoizdshyxgpIGu3MB9jZN2c6/TdSs3EsJLWN6Dqy4nMFo7Oe6/ulzTwITAT++gxCB5xaxXgyJ6SfVTCX4OgN23z+9K+ytWlOZglRZHWLLlqMD7NSUm6z+8IcdaC9FtTIOPtYmTj2S0mNhIG8WXEIxNwFbNyeuVnsqarSKpJp6FNdV6Wu+S7XG1rfkl0bbkswPxOV7VCE54DmW2mHh1cvbSD1P3siWTHyFkSJA7ihHGARFFE+IXhURVPCDTd5m5FVsW8qKXu/IfVYljO5i8y/w+H1pRv6xOA0vRi+xp3CPbms6BaImM+Q2yQFpbANUEGokToX0PYR0uRwgVV8P3zoqDyB9wMZdK/OqoLE7PzxP/+JCcg+XX1BZ56yv/ixdpiBE0UusYJ/T23o5HVSJIAtvKZcTkrGLDXmqq/ONsBvAalHP1AFS62JFhfoH27DG/Hsdp6",
    "@SubTotal""8694.10",
    "@Moneda""MXN",
    "@TipoCambio""1",
    "@Total""9737.40",
    "@TipoDeComprobante""I",
    "@MetodoPago""PPD",
    "@LugarExpedicion""80189",
    "@xmlns:cfdi""http://www.sat.gob.mx/cfd/3",
    "cfdi:Emisor": {
      "@Rfc""POMJ660311SW1",
      "@Nombre""JAVIER PONCE MARTINEZ",
      "@RegimenFiscal""612"
    },
    "cfdi:Receptor": {
      "@Rfc""RCA940729470",
      "@Nombre""RYDER CAPITAL, S. DE R.L. DE C.V.",
      "@UsoCFDI""G03"
    },
    "cfdi:Conceptos": {
      "cfdi:Concepto": [
        {
          "@ClaveProdServ""78101804",
          "@NoIdentificacion""12345-15",
          "@Cantidad""1.00",
          "@ClaveUnidad""E48",
          "@Descripcion""FLETE EN RUTA LOCAL CAMIONETA 1.5 TONELADAS",
          "@ValorUnitario""1722.00",
          "@Importe""1722.00",
          "cfdi:Impuestos": {
            "cfdi:Traslados": {
              "cfdi:Traslado": {
                "@Base""1722.00",
                "@Impuesto""002",
                "@TipoFactor""Tasa",
                "@TasaOCuota""0.160000",
                "@Importe""275.52"
              }
            },
            "cfdi:Retenciones": {
              "cfdi:Retencion": {
                "@Base""1722.00",
                "@Impuesto""002",
                "@TipoFactor""Tasa",
                "@TasaOCuota""0.040000",
                "@Importe""68.88"
              }
            }
          }
        },
        {
          "@ClaveProdServ""78101804",
          "@NoIdentificacion""12345-15",
          "@Cantidad""2.00",
          "@ClaveUnidad""E48",
          "@Descripcion""FLETE EN RUTA LOCAL CAMIONETA 3.5 TONELADAS",
          "@ValorUnitario""2198.55",
          "@Importe""4397.10",
          "cfdi:Impuestos": {
            "cfdi:Traslados": {
              "cfdi:Traslado": {
                "@Base""4397.10",
                "@Impuesto""002",
                "@TipoFactor""Tasa",
                "@TasaOCuota""0.160000",
                "@Importe""703.54"
              }
            },
            "cfdi:Retenciones": {
              "cfdi:Retencion": {
                "@Base""4397.10",
                "@Impuesto""002",
                "@TipoFactor""Tasa",
                "@TasaOCuota""0.040000",
                "@Importe""175.88"
              }
            }
          }
        },
        {
          "@ClaveProdServ""78101804",
          "@NoIdentificacion""12345-15",
          "@Cantidad""1.00",
          "@ClaveUnidad""E48",
          "@Descripcion""FLETE EN RUTA LOCAL RABON, CORRESPONDIENTE A HOJAS DE RUTA Nos. 3248, 3249, 3251, 3253",
          "@ValorUnitario""2575.00",
          "@Importe""2575.00",
          "cfdi:Impuestos": {
            "cfdi:Traslados": {
              "cfdi:Traslado": {
                "@Base""2575.00",
                "@Impuesto""002",
                "@TipoFactor""Tasa",
                "@TasaOCuota""0.160000",
                "@Importe""412.00"
              }
            },
            "cfdi:Retenciones": {
              "cfdi:Retencion": {
                "@Base""2575.00",
                "@Impuesto""002",
                "@TipoFactor""Tasa",
                "@TasaOCuota""0.040000",
                "@Importe""103.00"
              }
            }
          }
        }
      ]
    },
    "cfdi:Impuestos": {
      "@TotalImpuestosRetenidos""347.76",
      "@TotalImpuestosTrasladados""1391.06",
      "cfdi:Retenciones": {
        "cfdi:Retencion": {
          "@Impuesto""002",
          "@Importe""347.76"
        }
      },
      "cfdi:Traslados": {
        "cfdi:Traslado": {
          "@Impuesto""002",
          "@TipoFactor""Tasa",
          "@TasaOCuota""0.160000",
          "@Importe""1391.06"
        }
      }
    },
    "cfdi:Complemento": {
      "tfd:TimbreFiscalDigital": {
        "@xmlns:tfd""http://www.sat.gob.mx/TimbreFiscalDigital",
        "@Version""1.1",
        "@UUID""79185C0C-D8B1-481B-AEA8-148A81061E4A",
        "@FechaTimbrado""2021-12-16T11:13:44",
        "@RfcProvCertif""EEL961104G96",
        "@SelloCFD""e7wKQ2lrEoDvt/8PmCSZuyQ/ntsOhFV7R6onzUR/opcQaA6zsvJdmwQE0fojcaO8vizvQxPaCfn/n3KoSlRD00VkCBNT4FcWJQpc7V78OCmsnvO/BXyKSzTb2hzMydnLH70XSocTJK/5afYKd1ESIgqMv04upVHiqvR+CrIJdzWpQQmCuf/Gr3TlYNEhBaksDL+mF2FXUxD5XBXjXmcW5UskB6vgOejH4ZDuYQpcKwYvi1y6xyaCYYU9qW0Z32VIzE47kFnV3hTUYavGL9L3kVPIWzSgxPDEqdiO0cKdNRIHevGXfPkofyAVkQRlB2r3BOMucfpEDDVT/JAjaQnkBw==",
        "@NoCertificadoSAT""00001000000506194045",
        "@SelloSAT""SUjFfy54qumaaOvqgyGa2PK6iWm+2fq2ikW7JI9whtNCFMeQp0XHKjOeNDeBo6PDH4aJNupociLb1xkSrnC8LUlwHtbn512y5Rpc7dXhv+WE7WvWCJGO39K0c/NPUmsCL02heu3oezWeEmPwxw6NmAGGXO7q7GHuyVTz+c81gRJSs32oeIi3aDC9EWUt+/uLDvbCwzRxH0VTv4hOsrt3e3IYRbGQZWOpkt0q/5HHOcJuaPlH3iqjNtJbvA8Weoae7mdXheKrxPULmfRoPxV4RfHEvmIr1SayhtkPHMsjtryDm/CBB0jgkhG0BybcwUmpUL7gloFURdIp+AzpskKX8w=="
      }
    }
  }
}
 
Schema
{
  "type""object",
  "properties": {
    "?xml": {
      "type""object",
      "properties": {
        "@version": {
          "type""string"
        },
        "@encoding": {
          "type""string"
        }
      }
    },
    "cfdi:Comprobante": {
      "type""object",
      "properties": {
        "cfdi:Emisor": {
          "type""object",
          "properties": {
            "@Rfc": {
              "type""string"
            },
            "@Nombre": {
              "type""string"
            },
            "@RegimenFiscal": {
              "type""string"
            }
          }
        },
        "cfdi:Receptor": {
          "type""object",
          "properties": {
            "@Rfc": {
              "type""string"
            },
            "@Nombre": {
              "type""string"
            },
            "@UsoCFDI": {
              "type""string"
            }
          }
        },
        "cfdi:Conceptos": {
          "type""object",
          "properties": {
            "cfdi:Concepto": {
              "type""object",
              "properties": {
                "cfdi:Impuestos": {
                  "type""object",
                  "properties": {
                    "cfdi:Traslados": {
                      "type""object",
                      "properties": {
                        "cfdi:Traslado": {
                          "type""object",
                          "properties": {
                            "@Base": {
                              "type""string"
                            },
                            "@Impuesto": {
                              "type""string"
                            },
                            "@TipoFactor": {
                              "type""string"
                            },
                            "@TasaOCuota": {
                              "type""string"
                            },
                            "@Importe": {
                              "type""string"
                            }
                          }
                        }
                      }
                    },
                    "cfdi:Retenciones": {
                      "type""object",
                      "properties": {
                        "cfdi:Retencion": {
                          "type""object",
                          "properties": {
                            "@Base": {
                              "type""string"
                            },
                            "@Impuesto": {
                              "type""string"
                            },
                            "@TipoFactor": {
                              "type""string"
                            },
                            "@TasaOCuota": {
                              "type""string"
                            },
                            "@Importe": {
                              "type""string"
                            }
                          }
                        }
                      }
                    }
                  }
                },
                "@ClaveProdServ": {
                  "type""string"
                },
                "@NoIdentificacion": {
                  "type""string"
                },
                "@Cantidad": {
                  "type""string"
                },
                "@ClaveUnidad": {
                  "type""string"
                },
                "@Descripcion": {
                  "type""string"
                },
                "@ValorUnitario": {
                  "type""string"
                },
                "@Importe": {
                  "type""string"
                }
              }
            }
          }
        },
        "cfdi:Impuestos": {
          "type""object",
          "properties": {
            "cfdi:Retenciones": {
              "type""object",
              "properties": {
                "cfdi:Retencion": {
                  "type""object",
                  "properties": {
                    "@Impuesto": {
                      "type""string"
                    },
                    "@Importe": {
                      "type""string"
                    }
                  }
                }
              }
            },
            "cfdi:Traslados": {
              "type""object",
              "properties": {
                "cfdi:Traslado": {
                  "type""object",
                  "properties": {
                    "@Impuesto": {
                      "type""string"
                    },
                    "@TipoFactor": {
                      "type""string"
                    },
                    "@TasaOCuota": {
                      "type""string"
                    },
                    "@Importe": {
                      "type""string"
                    }
                  }
                }
              }
            },
            "@TotalImpuestosRetenidos": {
              "type""string"
            },
            "@TotalImpuestosTrasladados": {
              "type""string"
            }
          }
        },
        "cfdi:Complemento": {
          "type""object",
          "properties": {
            "tfd:TimbreFiscalDigital": {
              "type""object",
              "properties": {
                "@xmlns:tfd": {
                  "type""string"
                },
                "@xsi:schemaLocation": {
                  "type""string"
                },
                "@Version": {
                  "type""string"
                },
                "@UUID": {
                  "type""string"
                },
                "@FechaTimbrado": {
                  "type""string"
                },
                "@RfcProvCertif": {
                  "type""string"
                },
                "@SelloCFD": {
                  "type""string"
                },
                "@NoCertificadoSAT": {
                  "type""string"
                },
                "@SelloSAT": {
                  "type""string"
                }
              }
            }
          }
        },
        "@xmlns:xsi": {
          "type""string"
        },
        "@xsi:schemaLocation": {
          "type""string"
        },
        "@Version": {
          "type""string"
        },
        "@Serie": {
          "type""string"
        },
        "@Folio": {
          "type""string"
        },
        "@Fecha": {
          "type""string"
        },
        "@Sello": {
          "type""string"
        },
        "@FormaPago": {
          "type""string"
        },
        "@NoCertificado": {
          "type""string"
        },
        "@Certificado": {
          "type""string"
        },
        "@SubTotal": {
          "type""string"
        },
        "@Moneda": {
          "type""string"
        },
        "@TipoCambio": {
          "type""string"
        },
        "@Total": {
          "type""string"
        },
        "@TipoDeComprobante": {
          "type""string"
        },
        "@MetodoPago": {
          "type""string"
        },
        "@LugarExpedicion": {
          "type""string"
        },
        "@xmlns:cfdi": {
          "type""string"
        }
      }
    }
  }
}
 
Error Message
 
[
  {
    "message""Invalid type. Expected Object but got Array.",
    "lineNumber"0,
    "linePosition"0,
    "path""cfdi:Comprobante.cfdi:Conceptos.cfdi:Concepto",
    "schemaId""#/properties/cfdi:Comprobante/properties/cfdi:Conceptos/properties/cfdi:Concepto",
    "errorType""type",
    "childErrors": []
  }
]
 
AlfonsoLans_0-1641840797826.png

 

Hi @AlfonsoLans 

 

Your concepto array has 3 objects.  You would need to create an apply to each if you want to create 3 items.

 

This is a great tool for visualising a JSON array Best JSON Viewer and JSON Beautifier Online (codebeautify.org)

 

I have copied your sample JSON to a compose:

DamoBird365_2-1641841840437.png

 

And all 3 descriptions are output using following:

outputs('Compose')?['cfdi:Comprobante/cfdi:Conceptos/cfdi:Concepto']
 
DamoBird365_1-1641841799328.png

 

Damien

 

Awesome @DamoBird365 let me give it a shot, I am super new into this Thanks for your help, quick question does the 3 apply to each are created after the compose and on the Description type what kind of operation do I use, thanks in advance for your awesome help

AlfonsoLans
Frequent Visitor

Unfortunately I am not able to do it @DamoBird365 like I said I an new into this and I am not sure how to input those 3 new descriptions into the apply to each with the Compose

 

AlfonsoLans_0-1641844991530.png

 

For example on the apply to each I am copying the formula that you provided 

outputs('Compose')?['cfdi:Comprobante/cfdi:Conceptos/cfdi:Concepto']

 

Then you said that into the other 3 descriptions you said that:

 

And all 3 descriptions are output using following:

outputs('Compose')?['cfdi:Comprobante/cfdi:Conceptos/cfdi:Concepto']
 
But I see Item and other things in there, 
 
Apologize for not knowing 100% and again thanks a lot for your help
AlfonsoLans
Frequent Visitor

Not Sure what I am doing wrong but still gives me the same problem as before

 

AlfonsoLans_0-1641845749179.png

 

AlfonsoLans_1-1641845790850.png

Again apologize adn thanks for your support

Hi @AlfonsoLans 

 

A few things to understand here.  As I mentioned before, you have 3 objects.  You will therefore get 3 items.  The creation of the item would happen inside the apply to each.

 

The apply to each will loop through the 3 items.  I chose the description field as an example.

 

With the cfdi:concepto array as input per below, create an item with the description in the title. 

 

DamoBird365_0-1641846062936.png

 

Parse JSON is used to turn an array into dynamic values.  If you want to use this, place it before the apply to each, based on the output from you compose (which I assume is the full output).  Note you don't need to use Parse JSON if you understand how to create expressions. 

 

Here is a good article on JSON Power Automate: skip the Parse JSON action to reference data (microsoft.com) and why you don't need to use Parse if you work on your understanding.

 

Damien

 

AlfonsoLans
Frequent Visitor

Thanks @DamoBird365 for your great help, I will review into these topics and I will keep you posted on the result, just one more question I am getting the XML than I am Parsing the JSON to create the values that I need from the XML to populate my Sharepoint list and make it a lot more easier, as I can show you below, but when I received more than 1 row on the Description is when I and havin trouble, 

 

Let me show you below:

 

When the XML (in this case is a PDF of the XML) has 1 row all goes good

 

AlfonsoLans_0-1641846813584.png

 

But when there is more than 1 row is when I am having trouble, 

 

AlfonsoLans_1-1641846861874.png

 

On the single row the information is getting perfect to my sharepoint

 

AlfonsoLans_2-1641846952006.png

And the only time when the flow fails is when I have more than 1 row of information into the Concepto,

 

I just wanted to show you the whole thing just in case,

 

As far as building expressions I am not that good at it but I will review tha information that you have provided, that is why I was using the Parse Json information came out a lot better from the XML and is will be a lot easier to populate the sharepoint list

 

AlfonsoLans_3-1641847161993.png

Again Thanks a lot for your help Buddy appreciate it,

 

Helpful resources

Announcements
 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Users online (1,725)