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
HS_Nico
Helper II
Helper II

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.
HS_Nico
Helper II
Helper II

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]'

 

HS_Nico
Helper II
Helper II

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.

HS_Nico
Helper II
Helper II

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

Celebrating the May Super User of the Month: Laurens Martens

  @LaurensM  is an exceptional contributor to the Power Platform Community. Super Users like Laurens inspire others through their example, encouragement, and active participation. We are excited to celebrated Laurens as our Super User of the Month for May 2024.   Consistent Engagement:  He consistently engages with the community by answering forum questions, sharing insights, and providing solutions. Laurens dedication helps other users find answers and overcome challenges.   Community Expertise: As a Super User, Laurens plays a crucial role in maintaining a knowledge sharing environment. Always ensuring a positive experience for everyone.   Leadership: He shares valuable insights on community growth, engagement, and future trends. Their contributions help shape the Power Platform Community.   Congratulations, Laurens Martens, for your outstanding work! Keep inspiring others and making a difference in the community!   Keep up the fantastic work!        

Check out the Copilot Studio Cookbook today!

We are excited to announce our new Copilot Cookbook Gallery in the Copilot Studio Community. We can't wait for you to share your expertise and your experience!    Join us for an amazing opportunity where you'll be one of the first to contribute to the Copilot Cookbook—your ultimate guide to mastering Microsoft Copilot. Whether you're seeking inspiration or grappling with a challenge while crafting apps, you probably already know that Copilot Cookbook is your reliable assistant, offering a wealth of tips and tricks at your fingertips--and we want you to add your expertise. What can you "cook" up?   Click this link to get started: https://aka.ms/CS_Copilot_Cookbook_Gallery   Don't miss out on this exclusive opportunity to be one of the first in the Community to share your app creation journey with Copilot. We'll be announcing a Cookbook Challenge very soon and want to make sure you one of the first "cooks" in the kitchen.   Don't miss your moment--start submitting in the Copilot Cookbook Gallery today!     Thank you,  Engagement Team

Announcing Power Apps Copilot Cookbook Gallery

We are excited to share that the all-new Copilot Cookbook Gallery for Power Apps is now available in the Power Apps Community, full of tips and tricks on how to best use Microsoft Copilot as you develop and create in Power Apps. The new Copilot Cookbook is your go-to resource when you need inspiration--or when you're stuck--and aren't sure how to best partner with Copilot while creating apps.   Whether you're looking for the best prompts or just want to know about responsible AI use, visit Copilot Cookbook for regular updates you can rely on--while also serving up some of your greatest tips and tricks for the Community. Check Out the new Copilot Cookbook for Power Apps today: Copilot Cookbook - Power Platform Community.  We can't wait to see what you "cook" up!      

Tuesday Tip | How to Report Spam in Our Community

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   Today's Tip: How to Report Spam in Our Community We strive to maintain a professional and helpful community, and part of that effort involves keeping our platform free of spam. If you encounter a post that you believe is spam, please follow these steps to report it: Locate the Post: Find the post in question within the community.Kebab Menu: Click on the "Kebab" menu | 3 Dots, on the top right of the post.Report Inappropriate Content: Select "Report Inappropriate Content" from the menu.Submit Report: Fill out any necessary details on the form and submit your report.   Our community team will review the report and take appropriate action to ensure our community remains a valuable resource for everyone.   Thank you for helping us keep the community clean and useful!

Community Roundup: A Look Back at Our Last 10 Tuesday Tips

As we continue to grow and learn together, it's important to reflect on the valuable insights we've shared. For today's #TuesdayTip, we're excited to take a moment to look back at the last 10 tips we've shared in case you missed any or want to revisit them. Thanks for your incredible support for this series--we're so glad it was able to help so many of you navigate your community experience!   Getting Started in the Community An overview of everything you need to know about navigating the community on one page!  Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Community Ranks and YOU Have you ever wondered how your fellow community members ascend the ranks within our community? We explain everything about ranks and how to achieve points so you can climb up in the rankings! Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Powering Up Your Community Profile Your Community User Profile is how the Community knows you--so it's essential that it works the way you need it to! From changing your username to updating contact information, this Knowledge Base Article is your best resource for powering up your profile. Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Community Blogs--A Great Place to Start There's so much you'll discover in the Community Blogs, and we hope you'll check them out today!  Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Unlocking Community Achievements and Earning Badges Across the Communities, you'll see badges on users profile that recognize and reward their engagement and contributions. Check out some details on Community badges--and find out more in the detailed link at the end of the article! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Blogging in the Community Interested in blogging? Everything you need to know on writing blogs in our four communities! Get started blogging across the Power Platform communities today! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Subscriptions & Notifications We don't want you to miss a thing in the community! Read all about how to subscribe to sections of our forums and how to setup your notifications! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Getting Started with Private Messages & Macros Do you want to enhance your communication in the Community and streamline your interactions? One of the best ways to do this is to ensure you are using Private Messaging--and the ever-handy macros that are available to you as a Community member! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Community User Groups Learn everything about being part of, starting, or leading a User Group in the Power Platform Community. Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Update Your Community Profile Today! Keep your community profile up to date which is essential for staying connected and engaged with the community. Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Thank you for being an integral part of our journey.   Here's to many more Tuesday Tips as we pave the way for a brighter, more connected future! As always, watch the News & Announcements for the next set of tips, coming soon!

Hear what's next for the Power Up Program

Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp  

Users online (5,609)