Cperish/add id retrieval on create (#1)#121
Open
chrisperish wants to merge 1 commit into
Open
Conversation
* Added new REST create_record method which returns the id of the newly created record * Changelog update
3 tasks
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added new REST create_record method which returns the id of the newly created record
Changelog update