Fetch an X-CSRF-Token from SAP Gateway before issuing OData write requests

domain: sap-s4hana · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Send a HEAD or GET request to any OData service document (e.g. /$metadata) with header 'X-CSRF-Token: Fetch'
  2. Extract the token from the response header 'X-CSRF-Token' and capture all Set-Cookie values
  3. Include the token in the request header 'X-CSRF-Token: <token>' and forward the session cookies on every non-GET call (POST, PUT, PATCH, DELETE)
  4. On a 403 response with header 'X-CSRF-Token: Required', treat the token as expired, re-fetch, and retry the original request
  5. Use the same HTTP session (connection pool keyed to the session cookie) throughout to avoid token/session mismatch

Known gotchas

Related routes

Send an OData $batch request to SAP Gateway to group multiple entity operations in one HTTP call
sap-s4hana · 5 steps · unrated
Configure and test SAP OData v4 service on SAP Gateway with $filter, $expand, and deep insert
sap-s4hana · 5 steps · unrated
Authenticate to SAP SuccessFactors using OAuth 2.0 and read a single employee's record via the Employee Central OData v2 API.
help.sap.com · 6 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans