cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
lordfingle
Regular Visitor

Custom Connector for Xero : ResponseSwaggerSchemaValidationFailure Error details: 'The API operation 'xxxxxxx' requires the property 'body' to be of type 'String' but is of type 'Object'.'

I seem to be unable to invoke a REST action passing the body as a JSON object.  

 

Screenshot 2022-10-25 195525.png

I have created a custom connector.  It has several actions.  The custom connector uses OAUTH2.0 and works fine.  The actions that use GET parameters work fine.

 

In test mode in the custom connector the POST method "CreateInvoice" works fine.   (I am using the "Post Raw Body" option to test it).    It also works great in Postman.

 

When invoked from Power Automate it gets the error:

Error details: 'The API operation 'xxxxxxx' requires the property 'body' to be of type 'String' but is of type 'Object'.'

 

It appears that Power Automate deems anything that looks like a JSON object (such as the Output of a Compose) and object.

 

The body is defined as an object, yet the error seems to say that the custom connector is expecting a string. 

 

I have added/readded/reauthenticated the custom connector ad infinitum.

 

Any suggestions?

 

(Note: If I redefine the swagger to make the body a string it still works in test but I still get this error:

No data has been processed for this endpoint. This endpoint is expecting Invoice data to be specifed in the request body.)

 

More Detail

 

Here's the step:

Screenshot 2022-10-25 185609.png

 

Here's the run result:

Screenshot 2022-10-25 183615.png

Here is the error text:

 

 

The API 'xero-20invoices-yyyyyyyyyyyyyyyyyyyyyy' returned an invalid response for workflow operation 'xxxxxxxxxxxxxxx' of type 'OpenApiConnection'. Error details: 'The API operation 'CreateInvoice' requires the property 'body' to be of type 'String' but is of type 'Object'.'

 

 

 

Here is the swagger in the custom connector (only the post is relevant, but I included the get just in case):

 

Spoiler
  /api.xro/2.0/Invoices:
    get:
      summary: Invoices
      description: Gets a list of invoices
      operationId: Invoices
      parameters:
        - name: xero-tenant-id
          in: header
          required: true
          type: string
          default: '{{xero-tenant-id}}'
          description: xero-tenant-id
        - name: Accept
          in: header
          required: true
          type: string
          default: application/json
          description: Accept
          x-ms-visibility: internal
        - name: Content-Type
          in: header
          required: true
          type: string
          default: application/json
          description: Content-Type
          x-ms-visibility: internal
      responses:
        default:
          description: default
          schema: {}
    post:
      summary: Create Invoice
      description: Create Invoice
      operationId: CreateInvoice
      parameters:
        - name: summarizeErrors
          default: false
          in: query
          type: boolean
          required: true
          x-ms-visibility: internal
        - name: unitdp
          default: 4
          in: query
          type: integer
          required: true
          x-ms-visibility: internal
        - name: xero-tenant-id
          in: header
          required: true
          type: string
          default: '{{xero-tenant-id}}'
          description: xero-tenant-id
        - name: Content-Type
          in: header
          required: true
          type: string
          default: application/json
          description: Content-Type
          x-ms-visibility: internal
        - name: body
          in: body
          schema:
            type: object
            properties:
              Invoices:
                type: array
                items:
                  type: object
                  properties:
                    Type:
                      type: string
                      description: Type
                    Contact:
                      type: object
                      properties:
                        Name:
                          type: string
                          description: Name
                        EmailAddress:
                          type: string
                          description: EmailAddress
                      description: Contact
                    LineItems:
                      type: array
                      items:
                        type: object
                        properties:
                          Description:
                            type: string
                            description: Description
                          Quantity:
                            type: string
                            description: Quantity
                          UnitAmount:
                            type: string
                            description: UnitAmount
                          AccountCode:
                            type: string
                            description: AccountCode
                      description: LineItems
                    Date:
                      type: string
                      description: Date
                    Reference:
                      type: string
                      description: Reference
                description: Invoices
            default:
              Invoices:
                - Type: ACCREC
                  Contact:
                    Name: Mary Marker
                    EmailAddress: marymarker@blah.com
                  LineItems:
                    - Description: xxxxxxxxxxxxxx for Bill
                      Quantity: '1'
                      UnitAmount: '200'
                      AccountCode: '200'
                    - Description: xxxxxxxxxxxxxxx for Mary
                      Quantity: '1'
                      UnitAmount: '200'
                      AccountCode: '200'
                  Date: '2022-10-20'
                  Reference: ABC123
          required: true
      responses:
        '200':
          description: '200'
          schema:
            type: string
        '400':
          description: '400'
          schema:
            type: object
            properties:
              ErrorNumber:
                type: integer
                format: int32
                description: ErrorNumber
              Type:
                type: string
                description: Type
              Message:
                type: string
                description: Message
              Elements:
                type: array
                items:
                  type: object
                  properties:
                    ValidationErrors:
                      type: array
                      items:
                        type: object
                        properties:
                          Message:
                            type: string
                            description: Message
                      description: ValidationErrors
                    BatchPaymentID:
                      type: string
                      description: BatchPaymentID
                    BankTransactionID:
                      type: string
                      description: BankTransactionID
                    CreditNoteID:
                      type: string
                      description: CreditNoteID
                    ContactID:
                      type: string
                      description: ContactID
                    InvoiceID:
                      type: string
                      description: InvoiceID
                    ItemID:
                      type: string
                      description: ItemID
                    PurchaseOrderID:
                      type: string
                      description: PurchaseOrderID
                description: Elements

 

 

 

 

It looks like it's a similar problem to this one:

Custom Connector with raw body (JSON) 

 

 

 

 

0 REPLIES 0

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (4,037)