Invalid Order Book Parameters (invalid_order_book)
Quick Fix & Resolution
Provide valid selling_asset_type and buying_asset_type parameters along with code and issuer for credit assets.
Response Payload & SDK Handling
json
{
"type": "https://orion.stellarchain.io/horizon-errors/invalid_order_book",
"title": "Invalid Order Book Parameters",
"status": 400,
"detail": "The parameters that specify what order book to view are invalid in some way. Please ensure that your type parameters (selling_asset_type and buying_asset_type) are one of the following valid values: native, credit_alphanum4, credit_alphanum12. Also ensure that you have specified selling_asset_code and selling_asset_issuer if selling_asset_type is not 'native', as well as buying_asset_code and buying_asset_issuer if buying_asset_type is not 'native'."
}typescript
import { Horizon } from '@stellar/stellar-sdk';
const server = new Horizon.Server('https://pubnet.stellarchain.io');
try {
const res = await server.ledgers().limit(10).call();
} catch (err: any) {
const problem = err?.response?.data;
if (problem?.type === 'https://orion.stellarchain.io/horizon-errors/invalid_order_book') {
console.error('[invalid_order_book] HTTP 400:', problem.detail, problem.extras);
}
}go
client := &horizonclient.Client{
HorizonURL: "https://pubnet.stellarchain.io",
}
_, err := client.Root()
if hErr := horizonclient.GetError(err); hErr != nil {
if hErr.Problem.Status == 400 {
log.Printf("Problem (%s): %s - extras=%v", hErr.Problem.Type, hErr.Problem.Detail, hErr.Problem.Extras)
}
}bash
curl -i -s "https://pubnet.stellarchain.io/" \
-H "Accept: application/hal+json"Common Root Causes
selling_asset_typeorbuying_asset_typeis missing or not one ofnative,credit_alphanum4,credit_alphanum12.- Non-native asset is missing
*_asset_codeor a valid StrKey*_asset_issuer.