Problem of requesting API Ethereum: Using variables in parameters
As the development of Ethereum, but one common problem, which when working with variables, which should be conveyed as parameters. In this article,
“The signature of this request is incorrect” error
When sending the API interface in fate or any other tool, the exact syntax may vary depending on the end point of the API and its specific requirements. However, a common problem arises when variables are used without quotes.
Problem with {{}} syntax
In JavaScript Literals (`{...}) and interpolations of strings (
$ {…}) have different behaviors when it comes to variables. When you use `{}}, Postman interprets
{}
as the beginning of the variable name, which can lead to problems if the variable contains special signs or space.
Yes:
`Json
Post/API/Price HTTP/1.1
Content type: Application/JSON
{
"Price": "{{{selfrice}}",
"Symbol": "{{symbol}}"
}
If you use the `{}} syntax to convey a Sellprice variable, Postman will recognize it as a literal template and ignore the request in the body.
why {}} is incorrect
({...}} The signs around the variable using double curly clamps ({}}}}). This is the postman that the following parts are a replacement symbol for values:
`Json
Post/API/Price HTTP/1.1
Content type: Application/JSON
{
"Price": "{{{selfrice}}",
"Symbol": "{{symbol}}"
}
Solution
To use the variable {{Sellprice}} in the request, follow the following steps:
.
- Keep the rest of the intact syntax.
3.
Here is an updated example:
`Json
Post/API/Price HTTP/1.1
Content type: Application/JSON
{
"Price": "{{{selfrice}}",
"Symbol": "{{symbol}}"
}
Tips and variants
.
- For example:
`Json
Post/API/Price HTTP/1.1
Content type: Application/JSON
{
"Price": "'{{Sellprice}}'",
"Symbol": "'{{symbol}}'"
}
By following these steps, you should be able to successfully use your variable {{Sellprice}} in the API demand parameters.
Application
Using variables with special signs or space can lead to errors when sending demands to postman. Escaping `{}
around the variable with double curly clamps ({...}}}>
), you can make sure that Postman interprets and transfers your values correctly in accordance with the requirements.