You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have generated a API client based on a pretty large OpenAPI specification file (JSON format) when I am trying to call one of the endpoints via its operation identifier. I am having the issue that when I call clientsSearchPost it sends a request via the fetch-client with GET instead of POST.
The generated code does call post-function of the client but somehow it ends up being a GET which causes the request to fail with 404 as there is no GET counterpart of this endpoint.
Could it be that the interceptors are affecting the request method? I am using a request and response interceptor to support the fetching of OAuth2 client credentials tokens:
constclientConfig: HeyApiConfig=createHeyApiConfig({baseUrl: this.baseUrl,throwOnError: false,});this.apiClient=createHeyApiClient(clientConfig);this.apiClient.interceptors.request.use(async(request: Request)=>{awaitthis.ensureValidToken();constnewHeaders=newHeaders(request.headers);newHeaders.set('x-api-version',this.pinnedApiVersion);if(this.currentToken){newHeaders.set('Authorization',`Bearer ${this.currentToken}`);}returnnewRequest(request.url,{
...request,headers: newHeaders});});this.apiClient.interceptors.response.use(async(responseOrError: Response|any)=>{if(responseOrErrorinstanceofResponse){constresponse=responseOrErrorasResponse;if(response.status===401&&this.tokenConfig){console.log('Received 401 (in success path), attempting to refresh token...');this.currentToken=undefined;this.tokenExpiry=undefined;try{awaitthis.ensureValidToken();console.warn('Token refreshed after 401 in success path. Original request needs to be retried by the caller.');returnPromise.reject(newError(`Simulated error after 401 token refresh. Status: 401`));}catch(refreshError){console.error('Failed to refresh token during 401 handling:',refreshError);returnPromise.reject(responseOrError);}}returnresponse;}else{consterror=responseOrError;if(error?.response?.status===401&&this.tokenConfig){console.log('Received 401 (in error path), attempting to refresh token...');this.currentToken=undefined;this.tokenExpiry=undefined;try{awaitthis.ensureValidToken();console.warn('Token refreshed after 401 in error path. Original request needs to be retried by the caller.');returnPromise.reject(error);}catch(refreshError){console.error('Failed to refresh token during 401 handling:',refreshError);returnPromise.reject(error);}}returnPromise.reject(error);}});
@weyert Are you able to create a reproducible example? If not at least check your request interceptor and confirm the method ends up being POST, can't really help beyond that I'm afraid!
Uh oh!
There was an error while loading. Please reload this page.
Description
I have generated a API client based on a pretty large OpenAPI specification file (JSON format) when I am trying to call one of the endpoints via its operation identifier. I am having the issue that when I call
clientsSearchPost
it sends a request via thefetch
-client withGET
instead ofPOST
.The generated code does call
post
-function of the client but somehow it ends up being aGET
which causes the request to fail with 404 as there is noGET
counterpart of this endpoint.Reproducible example or configuration
The generated code for the earlier mentioned operation looks like:
Could it be that the interceptors are affecting the request method? I am using a request and response interceptor to support the fetching of OAuth2 client credentials tokens:
OpenAPI specification (optional)
Sadly can't share at this time
System information (optional)
MacOS: 15.5 (24F74)
Node.js: 23.11.0
PNPM: 9.15.2
NPM: 10.9.2
The text was updated successfully, but these errors were encountered: