iink SDK Web

Batch iink recognition service returned ERROR, {"code":"api.mapping.error", ...}

python code:

 

# coding: utf-8

import requests
import urllib
import hashlib
import json
import hmac

# keys
applicationKey = b'xxx'
hmacKey = b'yyy'
userKey = applicationKey + hmacKey

# load payload
payload = open('payload.json').read()

# calc sign
sign = hmac.new(userKey, payload.encode('utf-8'), hashlib.sha512).hexdigest()
print(f'sign: {sign}')

# post request
url = 'https://cloud.myscript.com/api/v4.0/iink/batch'
headers = {
    'Accept': 'application/x-latex,application/json',
    'Content-Type': 'application/json',
    'applicationKey': applicationKey,
    'hmac': sign
}
r = requests.post(url, data=json.dumps(payload), headers=headers)
print(r.content)

 error details:

 

b'{"code":"api.mapping.error","message":"Json mapping error: Cannot construct instance of `com.myscript.cloud.iink.message.receive.batch.BatchInput` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value (\'{\\n    \\"xDPI\\": 96,\\n    \\"yDPI\\": 96,\\n ...
...
 ]\\n                }\\n            ]\\n        }\\n    ]\\n}\')\\n at [Source: (PushbackInputStream); line: 1, column: 1]"}'

 

json

1 person has this question

Dear Qi Shen,


thank you for contacting us.


I could play your request with the following payload:

{"xDPI": 96,"yDPI": 96,"contentType": "Math","strokeGroups": [
{"penStyle": null,
    "strokes": [
        {"x": [323,323,323,323,324,324,325,326,329,331,333,334,335,338,342,344,345,347,349,352,354,358,361],"y": [246,249,253,257,260,265,271,278,289,297,304,309,313,311,304,296,285,270,259,249,245,241,239],"t": [1539161930051,1539161930103,1539161930137,1539161930153,1539161930169,1539161930187,1539161930202,1539161930219,1539161930236,1539161930253,1539161930269,1539161930286,1539161930303,1539161930436,1539161930453,1539161930469,1539161930486,1539161930502,1539161930519,1539161930536,1539161930553,1539161930586,1539161930619]},
        {"x": [380,384,390,394,397],"y": [290,291,290,290,290],"t": [1539161931094,1539161931169,1539161931186,1539161931203,1539161931219]},
        {"x": [365,368,371,377,386,395],"y": [303,305,305,305,305,304],"t": [1539161931460,1539161931504,1539161931519,1539161931537,1539161931553,1539161931570]},
        {"x": [464,462,460,458,455,454,455,459,462,465,468,471,474,473,472,471,470,470],"y": [240,244,250,255,263,266,269,268,267,266,264,262,259,263,267,275,279,282],"t": [1539161932128,1539161932220,1539161932236,1539161932254,1539161932270,1539161932287,1539161932320,1539161932336,1539161932354,1539161932370,1539161932386,1539161932405,1539161932453,1539161932519,1539161932536,1539161932553,1539161932569,1539161932602]},
        {"x": [442,450,457,460,471,479],"y": [298,298,297,296,295,296],"t": [1539161932879,1539161932953,1539161932974,1539161932987,1539161933003,1539161933019]},
        {"x": [451,454,458,462,466,467,460,457,461,464,468,471,473,466,461,451,446,442],"y": [316,314,313,312,312,316,321,322,323,324,326,329,333,338,340,340,338,336],"t": [1539161933364,1539161933487,1539161933503,1539161933520,1539161933537,1539161933587,1539161933619,1539161933636,1539161933703,1539161933719,1539161933736,1539161933753,1539161933773,1539161933804,1539161933830,1539161933853,1539161933875,1539161933895]},
        {"x": [512,511,511,511,511],"y": [285,290,294,300,303],"t": [1539161934496,1539161934620,1539161934636,1539161934653,1539161934672]},
        {"x": [523,523,522,522,522,522],"y": [281,288,293,297,302,307],"t": [1539161934880,1539161934970,1539161934987,1539161935003,1539161935020,1539161935036]},                                                                                                                                                                                                                                                                                                                            
        {"x": [482,486,491,498,510,529,541,550,553],"y": [277,277,278,278,277,275,273,272,272],"t": [1539161935360,1539161935419,1539161935437,1539161935453,1539161935470,1539161935486,1539161935503,1539161935519,1539161935531]},
        {"x": [539,542,543,545,548,552,555,553,551,550,549,554,560,564],"y": [308,306,301,296,295,296,298,302,305,309,312,314,312,310],"t": [1539161936290,1539161936369,1539161936404,1539161936436,1539161936552,1539161936587,1539161936620,1539161936653,1539161936669,1539161936687,1539161936719,1539161936753,1539161936786,1539161936803]},
        {"x": [570,573,576,579,582,581,577,574,579,583,585,585,578,573,570],"y": [282,281,280,279,279,282,285,287,288,292,296,299,300,300,300],"t": [1539161937256,1539161937403,1539161937436,1539161937453,1539161937487,1539161937519,1539161937552,1539161937586,1539161937669,1539161937703,1539161937735,1539161937772,1539161937819,1539161937836,1539161937853]
}]}]}



And the following headers:


See the result:


Please adapt your code accordingly, it should normally work.


Best regards,


Olivier

Year, it's okay now! thank you ~

Dear Qi Shen,


Thank you for the update. I am glad it is working.


Best regards,


Olivier