cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
oguruma
Helper III
Helper III

Custom Connector: Array for query parameter?

I'm building a Custom Connector for ERPNext. It uses the Filter Parameter to filter for criteria.

 

The Parameter accepts an array of arrays. For example 

 

https://erp.com/api/resource/Lead/?fields=["name"]&filters=[["company_name","=","Microsoft"],["rating",">","1"]]

 

would filter for Leads with the company name "Microsoft," and a Rating greater than 1, and retrieve the "Name" field.

 

The problem is that when I try to describe this in the Custom Connector Wizard, I get the error message 

 

Your custom connector has been successfully updated, but there was an issue converting it to WADL for Power Apps: An error occured while converting OpenAPI file to WADL file. Error: 'Parameter with type='array' is not currently supported at JSON path paths['/api/resource/Lead/'].get.parameters[0]'

 

 

My Swagger is 

 

swagger: '2.0'
info: {title: ERPNext, description: '', version: '1.0'}
host: erp.com
basePath: /
schemes: [https]
consumes: []
produces: []
paths:
  /api/resource/Lead/:
    get:
      responses:
        default:
          description: default
          schema: {}
      summary: Filter Leads By Company Name
      operationId: LeadsByCompanyName
      parameters:
      - {name: fields, in: query, required: false, type: array}
      - {name: filters, in: query, required: false, type: array}
definitions: {}
parameters: {}
responses: {}
securityDefinitions:
  basic_auth: {type: basic}
security:
- basic_auth: []
tags: []

 

In Swagger, for the Parameters, I get the message "Schemas with type Array require sibling "Item" fields. 

6 REPLIES 6

Hi @oguruma ,

 

try to use the official OpenAPI definition of ERPNext (ERPNext | 13 | alyf.de | SwaggerHub) in your connector. This has always worked well for me so far. Unfortunately I can't test it for your API because I don't have access to ERPNext.

 

Usually you can also create a connector directly from the definition (https://api.swaggerhub.com/apis/alyf.de/ERPNext/13), but unfortunately OpenAPI version 3 is still not supported.

 

I saw that version 14 of ERPNext already exists, unfortunately I could only find the OpenAPI definition in version 13.

Thanks for the input. I used an online tool to convert the V3 to V2 Swagger. I do get the error message below when I try to save the connector based on that definition. 

Specified swagger has the following errors: 'Definition is not valid. Error: 'Error : paths/~1method~1logout/get/responses/200/schema/default : The 'default' value is of type 'String', but should match the given type 'Object'. ## Error : paths/~1resource~1{DocType}/get/parameters/1/default : The 'default' value is of type 'String', but should match the given type 'Array'. '

 

swagger: '2.0'
info:
  version: '0.0.1'
  title: Frappe / ERPNext API
  description: >
    Unofficial documentation of the [Frappe](https://frappe.io) / [ERPNext](https://erpnext.org) API.
  contact:
    email: raffael@alyf.de
    name: Raffael Meyer
    url: https://alyf.de
host: demo.erpnext.com
basePath: /api
securityDefinitions:
  tokenAuth:
    type: apiKey
    description: >-
      Get your API keys at User -> Api Access -> Generate Keys.

      "headers = {'Authorization': 'token <api_key>:<api_secret>'}"
    name: Authorization
    in: header
  basicAuth:
    type: basic
    description: >
      Get your API keys at User -> Api Access -> Generate Keys.

      username = api_key; password = api_secret

      [More info](https://frappe.io/docs/user/en/guides/integration/token_based_auth)
  oAuth2:
    type: oauth2
    description: "This API uses OAuth 2 with the authorization code flow. \n[More info]https://frappe.io/docs/user/en/guides/integration/using_oauth)\n"
    flow: accessCode
    authorizationUrl: https://demo.erpnext.com/api/method/frappe.integrations.oauth2.authorize
    tokenUrl: https://demo.erpnext.com/api/method/frappe.integrations.oauth2.get_token
    scopes:
      all: Same permissions as the user who created the oAuth client
schemes:
- https
consumes:
- application/json
produces:
- application/json
paths:
  /method/login:
    post:
      description: Authenticate yourself
      summary: login
      tags:
      - Naive Authentication
      operationId: login
      deprecated: false
      produces:
      - application/json
      - text/html
      consumes:
      - application/x-www-form-urlencoded
      parameters:
      - name: usr
        in: query
        required: false
        type: string
        description: Your username
      - name: pwd
        in: query
        required: false
        type: string
        description: Your password
      - name: Content-Type
        in: header
        required: false
        enum:
        - application/x-www-form-urlencoded
        type: string
        description: ''
      - name: data
        in: formData
        required: false
        type: string
        description: ''
      responses:
        '200':
          description: Login successful
          schema:
            $ref: '#/definitions/MethodLoginResponse'
          headers: {}
        '401':
          description: oneOf(Incomplete login details, Incorrect password, User disabled or missing)
          schema:
            $ref: '#/definitions/MethodLogin401Error1'
          headers: {}
  /method/logout:
    get:
      description: Logout from current session
      summary: Logout from current session
      tags:
      - Naive Authentication
      operationId: Logoutfromcurrentsession
      deprecated: false
      produces:
      - application/json
      parameters: []
      responses:
        '200':
          description: Logged out.
          schema:
            type: object
            default: ''
          headers: {}
  /method/frappe.auth.get_logged_user:
    get:
      description: Get the currently logged in user
      summary: authGetLoggedUser
      tags:
      - Naive Authentication
      operationId: authGetLoggedUser
      deprecated: false
      produces:
      - application/json
      - text/html
      parameters: []
      responses:
        '200':
          description: search results matching criteria
          schema:
            $ref: '#/definitions/MethodFrappeAuthGetLoggedUserResponse'
          headers: {}
        '401':
          description: Not permitted
          schema:
            $ref: '#/definitions/MethodFrappeAuthGetLoggedUser401Error1'
          headers: {}
  /method/version:
    get:
      description: Get the version of the app
      summary: Get the version of the app
      operationId: Gettheversionoftheapp
      deprecated: false
      produces:
      - application/json
      parameters: []
      responses:
        '200':
          description: Successful
          schema:
            $ref: '#/definitions/MethodVersionResponse'
          headers: {}
  /resource/{DocType}:
    post:
      description: Create a new document
      summary: Create a new document
      operationId: Createanewdocument
      deprecated: false
      produces:
      - application/json
      - text/html
      consumes:
      - application/x-www-form-urlencoded
      parameters:
      - name: DocType
        in: path
        required: true
        type: string
        description: The DocType you'd like to receive. For example, Customer.
      - name: Content-Type
        in: header
        required: false
        enum:
        - application/x-www-form-urlencoded
        type: string
        description: ''
      - name: data
        in: formData
        required: false
        type: string
        description: ''
      responses:
        '200':
          description: Document created
          schema:
            $ref: '#/definitions/ResourceResponse'
          headers: {}
        '403':
          description: Insufficient Permission
          schema:
            $ref: '#/definitions/Resource403Error1'
          headers: {}
    get:
      description: Returns a list of documents of the given type
      summary: Get a list of documents
      operationId: Getalistofdocuments
      deprecated: false
      produces:
      - application/json
      parameters:
      - name: DocType
        in: path
        required: true
        type: string
        description: "The DocType you'd like to receive. For example Customer, Supplier, \nEmployee, Account, Lead, Company, Sales Invoice, Purchase Invoice, Stock Entry, etc."
      - name: fields
        in: query
        required: false
        default: >-
          [

            "name"

          ]
        type: array
        items:
          type: string
        description: "By default, only the \"name\" field is included in the listing, to add more fields, \nyou can pass the fields param to GET request. For example, fields=[\"name\",\"country\"]"
      - name: filters
        in: query
        required: false
        type: array
        items:
          type: array
          items:
            type: string
        description: >-
          You can filter the listing using sql conditions by passing them as the filters GET param.

          Each condition is an array of the format, [{doctype}, {field}, {operator}, {value}].

          For example, filters=[["Customer", "country", "=", "India"]]
      - name: limit_page_length
        in: query
        required: false
        default: 20
        type: integer
        format: int32
        description: "By default, all listings are returned paginated. With this parameter you can change the \npage size (how many items are teturned at once)."
      - name: limit_start
        in: query
        required: false
        default: 0
        type: integer
        format: int32
        description: "To request successive pages, pass a multiple of your limit_page_length as limit_start. \nFor Example, to request the second page, pass limit_start as 20."
      responses:
        '200':
          description: "Found requested DocType. By default, only the \"name\" field is included in the listing, \nto add more fields, you can pass the fields param to GET request."
          schema:
            $ref: '#/definitions/DocList'
          headers: {}
  /resource/{DocType}/{DocumentName}:
    get:
      description: Get a document by it's name, for example EMP001 of DocType Employee.
      summary: Get a specific document
      operationId: Getaspecificdocument
      deprecated: false
      produces:
      - application/json
      parameters:
      - name: DocType
        in: path
        required: true
        type: string
        description: "The DocType you'd like to receive. For example Customer, Supplier, \nEmployee, Account, Lead, Company, Sales Invoice, Purchase Invoice, Stock Entry, etc."
      - name: DocumentName
        in: path
        required: true
        type: string
        description: The name (ID) of the document you'd like to receive. For example EMP001 (of type Employee).
      responses:
        '200':
          description: Found requested document
          schema:
            $ref: '#/definitions/ResourceResponse'
          headers: {}
    put:
      description: TBD
      summary: Update a specific document
      operationId: Updateaspecificdocument
      deprecated: false
      produces:
      - application/json
      parameters:
      - name: DocType
        in: path
        required: true
        type: string
        description: "The DocType you'd like to update. For example Customer, Supplier, \nEmployee, Account, Lead, Company, Sales Invoice, Purchase Invoice, Stock Entry, etc."
      - name: DocumentName
        in: path
        required: true
        type: string
        description: The name (ID) of the document you'd like to update. For example EMP001 (of type Employee).
      responses:
        '200':
          description: Updated specified document
          schema:
            $ref: '#/definitions/ResourceResponse'
          headers: {}
    delete:
      description: TBD
      summary: Delete a specific document
      operationId: Deleteaspecificdocument
      deprecated: false
      produces:
      - application/json
      parameters:
      - name: DocType
        in: path
        required: true
        type: string
        description: "The type of the document you'd like to delete. For example Customer, Supplier, \nEmployee, Account, Lead, Company, Sales Invoice, Purchase Invoice, Stock Entry, etc."
      - name: DocumentName
        in: path
        required: true
        type: string
        description: The name (ID) of the document you'd like to delete. For example EMP001 (of type Employee).
      responses:
        '202':
          description: Deleted specified document
          schema:
            $ref: '#/definitions/ResourceResponse3'
          headers: {}
definitions:
  DocType:
    title: DocType
    type: object
    properties:
      name:
        type: string
      modified_by:
        type: string
      creation:
        type: string
      modified:
        type: string
      doctype:
        type: string
      owner:
        type: string
      docstatus:
        type: integer
        format: int32
  DocList:
    title: DocList
    type: object
    properties:
      data:
        type: array
        items:
          $ref: '#/definitions/DocType'
  MethodFrappeAuthGetLoggedUser401Error1:
    title: MethodFrappeAuthGetLoggedUser401Error1
    type: object
    properties:
      exc:
        example: Traceback (most recent call last) ...
        type: string
      _server_messages:
        example:
        - message: Not permitted
        type: string
  MethodFrappeAuthGetLoggedUserResponse:
    title: MethodFrappeAuthGetLoggedUserResponse
    type: object
    properties:
      message:
        example: demo@erpnext.com
        type: string
  MethodLogin401Error1:
    title: MethodLogin401Error1
    type: object
    properties:
      exc:
        example: Traceback (most recent call last) ...
        type: string
      message:
        example: Incorrect password
        type: string
  MethodLoginResponse:
    title: MethodLoginResponse
    type: object
    properties:
      full_name:
        example: Administrator
        type: string
      message:
        example: Logged in
        type: string
      home_page:
        example: /desk
        type: string
  MethodVersionResponse:
    title: MethodVersionResponse
    type: object
    properties:
      message:
        example: 10.1.36
        type: string
  Resource403Error1:
    title: Resource403Error1
    type: object
    properties:
      exc:
        example: Traceback (most recent call last) ...
        type: string
      _error_message:
        example: Insufficient Permission for {DocType}
        type: string
  ResourceResponse:
    title: ResourceResponse
    type: object
    properties:
      data:
        $ref: '#/definitions/DocType'
  ResourceResponse3:
    title: ResourceResponse3
    type: object
    properties:
      message:
        type: string
security: []
tags:
- name: Naive Authentication
  description: If you are developing something serious, you may want to use oAuth2.

To fix the error you need to append "items: {type: string}" to your parameter definition. You do that in Swagger Editor. Your code should then look like this:

parameters:
- {name: fields, in: query, required: false, type: array, items: {type: string}}
- {name: filters, in: query, required: false, type: array, items: {type: string}}

I believe I found the offending part in Swagger.

 

        default: "[\n\n  \"name\"\n\n]"

 

When I delete that line, the error message goes away. The default value is an array with "name" in it, but swagger is evaluating "[\n\n \"name\"\n\n]" as a string, instead of as an array. What's the proper way to denote a literal array for a default value?

 

Even after deleting the offending line, and getting rid of the error message, I can save the Connector, but I still receive the message 

Your custom connector has been successfully updated, but there was an issue converting it to WADL for Power Apps: An error occured while converting OpenAPI file to WADL file. Error: 'Parameter with type='array' is not currently supported at JSON path paths['/resource/{DocType}'].get.parameters[1]'

 

Ignore my suggestion with the official OpenAPI documentation and build your connector manually. Then you will again face the problem of your introductory question ("Schemas with type Array require sibling "Item"), which you can fix with my second answer.

Has your problem now been resolved? If my answer helped you, I would be happy if you would accept it as a solution.

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!   This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions in the Forums to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersNumber of SolutionsSuper UsersNumber of Solutions @anandm08  23 @WarrenBelz  31 @DBO_DV  10 @Amik  19 AmínAA 6 @mmbr1606  12 @rzuber  4 @happyume  7 @Giraldoj  3@ANB 6 (tie)   @SpongYe  6 (tie)     Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersSolutionsSuper UsersSolutions @anandm08  10@WarrenBelz 25 @DBO_DV  6@mmbr1606 14 @AmínAA 4 @Amik  12 @royg  3 @ANB  10 @AllanDeCastro  2 @SunilPashikanti  5 @Michaelfp  2 @FLMike  5 @eduardo_izzo  2   Meekou 2   @rzuber  2   @Velegandla  2     @PowerPlatform-P  2   @Micaiah  2     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 3:Community MembersSolutionsSuper UsersSolutionsPower Apps anandm0861WarrenBelz86DBO_DV25Amik66Michaelfp13mmbr160647Giraldoj13FLMike31AmínAA13SpongYe27     Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 4:Community MembersSolutionsSuper UsersSolutionsPower Apps DBO-DV21WarranBelz26Giraldoj7mmbr160618Muzammmil_0695067Amik14samfawzi_acml6FLMike12tzuber6ANB8   SunilPashikanti8

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (977)