postmanlabs / postmanlabs/postman-code-generators

code-snippets generator for M language (microsoft power query)

Open
#754 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
1k
Forks
381
PR merge metrics
No merged PRs in 30d

Description

Is your feature request related to a problem? Please describe.
Postman offers a generate-code-snippets feature for various supported language, currently, there is no snippet for M language to query with Power Platform using web API.

Describe the solution you'd like
Provide a M Code to request web API in M

Additional context
Please find below an example of M Code for Quonto web API with API-KEY authentication.
using some header parameters the request GET results and combine pages into one database as a structured table (in one column) according to fields label.

`let
// Auteur : Alexandre STEVENS - https://www.formationpowerbi.fr

// Paramètres de l'API
api_url = "https://thirdparty.qonto.com/v2/transactions",
api_key = "ID:APIKEY",
iban = "IBAN",
slug = "ID",
nb_pages = 10,

// Fonction pour récupérer les transactions d'une page donnée
get_transactions = (pageNumber) =>
    let
        // Paramètres de la requête
        params = [
            #"slug"= slug,
            #"iban"= iban,
            #"current_page"= Text.From(pageNumber)
        ],

        // En-têtes de la requête
        headers = [Authorization=api_key],

        // Appel de l'API
        Source = Json.Document(Web.Contents(api_url, [Query=params, Headers=headers])),

        // Extraction des transactions
        transactions = Source[transactions],

        // Conversion en table
        table = Table.FromList(transactions, Splitter.SplitByNothing(), null, null, ExtraValues.Error)
    in
        table,

// Nombre total de pages à requêter
total_pages = nb_pages,

// Liste pour stocker les résultats de chaque page
all_pages = List.Generate(() => 1, each _ <= total_pages, each _ + 1, each get_transactions(_)),

// Fusion de toutes les pages en une seule table
df_all = Table.Combine(all_pages),

// Expansion des colonnes
database = Table.ExpandRecordColumn(df_all, "Column1", {"transaction_id", "amount", "amount_cents", "settled_balance", "settled_balance_cents", "attachment_ids", "local_amount", "local_amount_cents", "side", "operation_type", "currency", "local_currency", "label", "settled_at", "emitted_at", "updated_at", "status", "note", "reference", "vat_amount", "vat_amount_cents", "vat_rate", "initiator_id", "label_ids", "attachment_lost", "attachment_required", "card_last_digits", "category", "id", "subject_type", "income", "transfer", "direct_debit"}, {"transaction_id", "amount", "amount_cents", "settled_balance", "settled_balance_cents", "attachment_ids", "local_amount", "local_amount_cents", "side", "operation_type", "currency", "local_currency", "label", "settled_at", "emitted_at", "updated_at", "status", "note", "reference", "vat_amount", "vat_amount_cents", "vat_rate", "initiator_id", "label_ids", "attachment_lost", "attachment_required", "card_last_digits", "category", "id", "subject_type", "income", "transfer", "direct_debit"})

in
database
`

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No file or test is named in the issue. Start by comparing the repository's existing code generators and their registration points, then determine how the supplied Power Query M example should represent the requested API call and pagination. Done means Postman can generate an M snippet for supported requests and the generator is covered by the repository's applicable tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, postman
Domain
api, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.