Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help Needed with Jupiter API Swap Execution - "Failed to Deserialize JSON" Error #48

Open
scatterblast opened this issue Jan 9, 2025 · 0 comments

Comments

@scatterblast
Copy link

Hello,

I’ve been working on integrating Jupiter’s API to build a trading bot and have successfully implemented the following:

  1. Quote API:

Successfully retrieved valid quotes from the /v6/quote endpoint using Postman and my application code.

Example response from /v6/quote:

{
"inputMint": "So11111111111111111111111111111111111111112",
"inAmount": "100000000",
"outputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"outAmount": "19299219",
"routePlan": [
{
"swapInfo": {
"ammKey": "5zvhFRN45j9oePohUQ739Z4UaSrgPoJ8NLaS2izFuX1j",
"inputMint": "So11111111111111111111111111111111111111112",
"outputMint": "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",
"inAmount": "100000000",
"outAmount": "19268051",
"feeAmount": "10000",
"feeMint": "So11111111111111111111111111111111111111112"
},
"percent": 100
}
]
}

  1. Swap API:

I am attempting to execute a swap using the /v6/swap endpoint with the routePlan provided by the quote API.


Problem Statement

Despite following the documentation, I am encountering the following error when attempting to call /v6/swap:

{
"error": "Failed to deserialize the JSON body into the target type"
}


Current Setup

Here’s the payload I’m sending to /v6/swap:

{
"inputMint": "So11111111111111111111111111111111111111112",
"outputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"amount": "100000000",
"slippageBps": 50,
"userPublicKey": "CzecDkTumsPDkRfksDeXGvinCd3P4aTFUSt7UpktFjoL",
"routePlan": [
{
"ammKey": "5zvhFRN45j9oePohUQ739Z4UaSrgPoJ8NLaS2izFuX1j",
"inputMint": "So11111111111111111111111111111111111111112",
"outputMint": "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",
"inAmount": "100000000",
"outAmount": "19268051",
"feeAmount": "10000",
"feeMint": "So11111111111111111111111111111111111111112"
}
]
}

Key Details:

Headers Used:

{
"Content-Type": "application/json",
"Accept": "application/json"
}

Environment: Mainnet

Libraries Used: Postman for testing and Node.js (with axios for HTTP requests).


Steps Taken to Debug:

  1. Validated Payload:

Verified the JSON payload using JSONLint to ensure it is properly formatted.

Cross-checked the payload against the /v6/swap documentation.

  1. Confirmed Route Details:

The routePlan field was directly extracted from the /v6/quote response.

Confirmed that inputMint, outputMint, and ammKey are valid Solana addresses.

  1. Tested in Postman:

The same error occurs when testing with Postman, confirming the issue is not specific to my application.

  1. Tried Simplified Payloads:

Removed routePlan and sent only required fields to see if the error changes. The same error persists.


Request for Assistance

Could you please help me identify:

  1. If there are any known issues or specific formatting requirements for the routePlan or the entire payload that I might have missed?

  2. If additional headers, authentication tokens, or other parameters are required?

  3. Any specific debugging tools or techniques recommended for this endpoints?

Thank you in advance!

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

No branches or pull requests

1 participant