no problem, just continue with Java, it’s solid (=
What’s the request that returns this?
val url = "https://www.wanikani.com/api/user/18287822e799e86b4ad2cbdd068e85d9/vocabulary/1"
val request = JsonObjectRequest(
Request.Method.GET, url, null,
Response.Listener<JSONObject> { response ->
try {
val jsonArray = response.getJSONArray("requested_information")
for (i in 0 until jsonArray.length()) {
val jsonObject = jsonArray.getJSONObject(i)
// Append character to textView here
val cha = jsonObject.getString("character")
val burn = jsonObject.getString("user_specific")
I think because I parse level 1 at the end of the url, how can I parse everything till my highest level
Is there a reason you’re using API v1 instead of v2? Not sure when, but they’re going to kill v1 at some point.
have you tried leaving out the “/1”?
And why are you not using the v2 request as Kumirei suggested?
https://api.wanikani.com/v2/assignments?burned=true&subject_types=vocabulary
Not sure about V1 but with V2 you can use this
https://api.wanikani.com/v2/assignments?burned=true&subject_types=vocabulary&levels=1,2,3,4,5,6,7,8,9,10,11,12,13
I also need to change the array request right? Like where do I find the jsonArray string that belongs to the api string? Like you can see in the code above.
I read the title as Wanikani Scriptures and was hoping for some much needed Crabigatorism enlightenment
I’ll show myself out now
The response in V2 doesn’t have a “requested_information” field, but I guess replacing it with “data” would do just fine. You can see in the example here that “data” would be pretty much the same thing as “requested_information” in V1.
Sorry, guys that I ask so much, first time building my app, and really striving to finish it, not to give up like the others app I tried to build. i’m Just totally noob, that’s it.
I tried it out and get {“error”:“Unauthorized. Nice try.”,“code”:401}
You need to put your API key in a header, as in the example request in the image in my last post
I got that, I stored it in a val url, val url = "https://api.wanikani.com/v2/assignments?burned=true&subject_types=vocabulary&levels=1,2,3,4,5,6,7,8,9,10,11,12,13"
What you need to do is pass your API key as a header, like this "Authorization: Bearer <api_token_here>"
. I’m not familiar with Java so Googled it. I think this SO answer should tell you how to do it. Otherwise you could probably ask one of the mobile devs on here.
I created the getheader method, I still get the error, I don’t know if this right.
}
} catch (e: JSONException) {
e.printStackTrace()
}
getHeaders()
}, Response.ErrorListener { error -> error.printStackTrace() })
mQueue!!.add(request)
}
@Throws(AuthFailureError::class)
fun getHeaders(): Map<*, *>? {
val headers = HashMap<Any, Any>()
headers["Content-Type"] = "application/json"
headers["apiKey"] = "https://api.wanikani.com/v2/assignments?burned=true&subject_types=vocabulary&levels=1,2,3,4,5,6,7,8,9,10,11,12,13"
return headers
}
for reference, this is the error that’s still returned: