Skip to content

Add React Web API create-record sample#90

Draft
MrRishabhJain wants to merge 1 commit into
mainfrom
add-web-api-create-record-sample
Draft

Add React Web API create-record sample#90
MrRishabhJain wants to merge 1 commit into
mainfrom
add-web-api-create-record-sample

Conversation

@MrRishabhJain

Copy link
Copy Markdown

What this does

Adds a new, single-concept SPA code-site sample: Web API: Create a Record
(samples/spa/react/web-api-create-record/).

It demonstrates exactly one thing — how to create a Dataverse record from a
Power Pages code site using the Web API (HTTP POST)
— in keeping with the
goal of samples that are easy for a human developer to follow.

Why

The existing Web API coverage across the repo is read-heavy: every sample shows
GET, and the only write (PATCH) is buried inside the full Credit Cards
banking app. There was no focused, copy-pasteable example of creating a record,
which is one of the most common things customers ask for. This sample isolates
that concept.

What's in the sample

  • The entire concept lives in one commented file, src/api/webApi.ts:
    • fetch the anti-forgery token (/_layout/tokenhtml),
    • POST to /_api/sample_feedbacks with the OData headers,
    • read the new record GUID from the OData-EntityId response header.
  • A minimal "Share your feedback" form (FeedbackForm.tsx) — no UI framework,
    just React + Vite + TypeScript to keep the signal high.
  • A dev-mode mock so npm run dev is explorable without a deployed site.
  • A README that leads with the Power Pages config that actually matters: the
    table schema, the Web API site settings, and the Create table
    permission
    (including the HTTP 403 path when it's missing).

Discoverability fixes

  • Added the sample to the root README.md and samples/spa/README.md tables.
  • Surfaced the previously-undocumented server-logic category: new
    samples/server-logic/README.md and a row in the root README for the
    existing SharePoint Integration sample.

Verification

  • npm install and npm run build (strict tsc + Vite) pass.
  • screenshot.png is a real capture of the running app.
  • node_modules/dist are gitignored; only source files are tracked.

Notes

  • I intentionally did not hand-author the .powerpages-site/ metadata shell
    (it carries site-specific GUIDs and can't be validated without a live org).
    pac pages upload-code-site regenerates that shell; the meaningful Power Pages
    configuration is documented in the sample README instead.

Opened as a draft for early feedback on the approach. If the direction is
good, I have follow-up single-concept samples queued: file upload/download,
trigger a Power Automate flow, and a table-permissions sample.

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

Add a focused, single-purpose SPA code-site sample that creates a Dataverse record via the Power Pages Web API (HTTP POST), covering the anti-forgery token, OData headers, Web API site settings, and a Create table permission.

Also surface the previously-undocumented server-logic category in the READMEs and list the new sample in the root and SPA sample tables.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant