The Hearthstone cards API endpoint returns a 200 response with the following body when a % character is present in the textFilter parameter:
{
“error”: {
“status”: 200,
“statusMessage”: “OK”
}
}
This also causes the card library page on the Hearthstone website to break if you include a % in the search string.
Steps to reproduce: Include a % in the textFilter parameter string
Expected outcome: A 200 response with a body containing cardCount = 0 and an empty array of cards.
Actual outcome: A 200 response with an error field.
I’m not really familiar with the HS api, but if the text you are searching includes a %
make sure to urlencode
the text. For instance the encoded version of a %
is %25
.
It returns the same error with both the regular character (%) and the encoded version (%25)
I think this is indeed a bug, but I think I found the cause and probably a workaround. I think somehow there is a double decoding happening for %
.
I successfully made a request using %2525
instead of %25
:
This request:
https://us.api.blizzard.com/hearthstone/cards?locale=en_US&textFilter=they%20have%20a%2050%2525&access_token=<TOKEN>
Returned me:
{
"cards": [
{
"id": 39046,
"collectible": 1,
"slug": "39046-nat-the-darkfisher",
"classId": 12,
"multiClassIds": [],
"cardTypeId": 4,
"cardSetId": 21,
"rarityId": 5,
"artistName": "Steve Prescott",
"health": 4,
"attack": 2,
"manaCost": 2,
"name": "Nat, the Darkfisher",
"text": "At the start of your opponent's turn, they have a 50% chance to draw an extra card.",
"image": "https://d15f34w2p8l1cc.cloudfront.net/hearthstone/796fa64ed422453a6789f5bc675ef7c5fd8a5594bad20c4a4287c86a1d08bc37.png",
"imageGold": "",
"flavorText": "You can take away his humanity, but you will never take away his fishing pole.",
"cropImage": "https://d15f34w2p8l1cc.cloudfront.net/hearthstone/844d373448c2bdfffef11d8f872cf206c957581b66ae471f1dfb7d14a2a9cae8.jpg"
}
],
"cardCount": 1,
"pageCount": 1,
"page": 1
}
Hope it helps somehow.
Yeah, I found the same thing. Must be getting decoded twice like you said.
A workaround should be simple enough to add until this is fixed.
Cheers.