Skip to content

Cperish/add id retrieval on create (#1)#121

Open
chrisperish wants to merge 1 commit into
jacobsvante:mainfrom
chrisperish:main
Open

Cperish/add id retrieval on create (#1)#121
chrisperish wants to merge 1 commit into
jacobsvante:mainfrom
chrisperish:main

Conversation

@chrisperish

Copy link
Copy Markdown
  • Added new REST create_record method which returns the id of the newly created record

  • Changelog update

* Added new REST create_record method which returns the id of the newly created record

* Changelog update
vlouvet added a commit to vlouvet/netsuite that referenced this pull request Jun 17, 2026
NetSuite answers a REST create with 204 No Content and a Location header
pointing at the new record, so the JSON-only _request helper (which returns
None on 204) gives callers no way to learn the assigned ID.

Add create_record(record_type, record_data): it POSTs to
/record/v1/{record_type} via _request_impl directly (the same pattern
batch() uses to reach the Location header), then returns the ID parsed from
that header -- an int for numeric IDs, the raw string for external IDs
(eid:...), or None when no Location is present.

This is a scoped reimplementation of the idea in PR jacobsvante#121. Unlike that PR it
does not mutate the generic _request to special-case every 204 POST (which
would silently change the return type of all POSTs), and the ID parser
ignores query strings/fragments and tolerates a trailing slash rather than
using a bare /([^/]+)$ regex that would capture a querystring.

Tested: collection-endpoint POST + body, numeric id -> int, external id ->
str, query/trailing-slash handling, missing-header -> None, error status
raises.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.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