Bugsense returns error: "list index out of range"

170 Views Asked by At

I'm currently developing a bugsense plugin for Corona. The function performing the request is:

local function sendLog(request) 
    local headers = {}

    headers["Content-Type"] = "application/json"
    headers["X-BugSense-Api-Key"] = "XXXXXXXXX"

    local params = {}
    params.headers = headers

    params.body =json.encode(request)

    network.request( "http://www.bugsense.com/api/errors", "POST", networkListener, params)
end

The request is executed perfectly, but API returns the following error:

{
    "data": null,
    "error": "list index out of range"
}

The petition sent to BUgsense is:

{
    "client": {
        "name": "bugsense-ios",
        "version": "0.6"
    },
    "exception": {
        "message": "XXXX",
        "klass": "",
        "where": "",
        "backtrace": "XXXXX"
    },
    "application_environment": {
        "appver": "2.0",
        "uid": "XXXXX",
        "mobile_net_on": "false",
        "phone": "iPad",
        "appname": "app",
        "wifi_on": "false",
        "osver": "10.9"
    }
}

Obviously, all the XXXXX are replacing sensitive information.

Could anybody help me on what's wrong in the request to originate that error message?

Thanks in advance

2

There are 2 best solutions below

0
ryosua On

Don't know if this will work, but if your stuck it's worth a try: Try indexing headers with numbers instead of strings.

headers[1] = "application/json"
headers[2] = "XXXXXXXXX"
0
Sergi and Replace On

Answering my own question for future references

The issue was generated because not all fields were included. All the fields in exception group must be included and non-empty. Even if the instructions from Bugsense are not indicating them as mandatory.

Hope this helps