<@U04UQ68083H> How do I get the actual status code...
# ory-copilot
c
@chilly-king-10285 How do I get the actual status code from the error I’m getting when I fire against this API: identityAPI.createIdentity({ createIdentityBody })
b
A message from kapa.ai
To get the actual status code from the error when calling the Ory Identity API's
createIdentity
method (e.g.,
identityAPI.createIdentity({ createIdentityBody })
), you need to inspect the error object returned by the API client. The Ory API returns errors in a standard JSON format, which includes a status code field. For example, in the error response, you will find a field such as
status_code
(for Ory Network) or
code
(for Ory Kratos) within the error object: - For Ory Network, the error response includes:
Copy code
json   {     "error": {       "status_code": 400,       "message": "Message contains the error message.",       ...     }   }
- For Ory Kratos, the error response includes:
Copy code
json   {     "error": {       "code": 400,       "message": "Error message",       ...     }   }
So, after catching the error, you should access
error.response.data.error.status_code
(Ory Network) or
error.response.data.error.code
(Ory Kratos) to get the actual status code, depending on which Ory product you are using. If you are using the Go SDK, the HTTP response object (
r
) also contains the status code as `r.StatusCode`[Ory API Reference - createIdentity](https://www.ory.sh/docs/reference/api). Example (JavaScript/TypeScript):
Copy code
js try {   await identityAPI.createIdentity({ createIdentityBody }); } catch (error) {   // For Ory Network   const statusCode = error.response?.data?.error?.status_code;   // For Ory Kratos   // const statusCode = error.response?.data?.error?.code;   console.log('Status code:', statusCode); }
Example (Go SDK):
Copy code
go createdIdentity, r, err := apiClient.IdentityApi.CreateIdentity(ctx).CreateIdentityBody(body).Execute() if err != nil {     fmt.Println("Status code:", r.StatusCode) }
[Ory API Reference - createIdentity](https://www.ory.sh/docs/reference/api)
c
@chilly-king-10285 All I’m getting is this: { “response”: {}, “name”: “ResponseError” }
b
A message from kapa.ai
Based on the knowledge sources provided, the Ory Identity API returns errors in a standard JSON format that includes fields such as
status_code
(Ory Network) or
code
(Ory Kratos) inside the
error
object of the response body. However, if you are only seeing an empty
response
object and a
name
of
"ResponseError"
, this suggests that the error handling in your client or SDK is not exposing the full error response from the API. The knowledge sources do not provide details about SDK-specific error handling or what to do if the error object is empty. They only describe the expected error response format from the API side, not how the client should handle or expose it. Therefore, I cannot provide a definitive solution for your specific client-side issue based on the available documentation. If you are not receiving the expected error structure, you may need to: - Check if your HTTP client or SDK is configured to parse and expose the response body. - Inspect the raw HTTP response (e.g., using network tools or additional logging) to see if the API is returning more information that your client is not displaying. I'm sorry, but the knowledge sources do not contain enough information to explain why you are only seeing an empty
response
object and how to resolve this in your client code. For further troubleshooting, you may need to consult the SDK documentation or seek support from the Ory community.
c
What is the github link for the JS SDK
@chilly-king-10285 What is the github link for the JS client-fetch sdk
b
A message from kapa.ai
The knowledge sources do not provide a direct GitHub link for the JS
@ory/client-fetch
SDK. They mention the [npm package for @ory/client-fetch](https://www.npmjs.com/package/@ory/client-fetch), but do not specify a GitHub repository URL for this SDK. If you need the source code, you may want to check the [Ory SDKs GitHub repository](https://github.com/ory/sdk/tree/master/clients/client), but the exact location for
@ory/client-fetch
is not explicitly stated in the provided documentation [Ory API Reference](https://www.ory.sh/docs/reference/api).