0

I am trying to using Mobile SDK to upload file and I'm logged in too (other services I tested are working fine),
Now I am trying to upload files (specifically images in my case) as described here:

FileRequests.uploadFile(myFile, myFile.name, "Test Title", "Test Description", "image/jpeg")

where myFile is an image in the storage with file path as something like this (I have the runtime dangerous storage permissions for android too):

/storage/emulated/0/Android/data/com.myappp/files/Pictures/JPEG_20200609_134028_32666.jpg

And then calling the sendAsync() method as below :

client.sendAsync(request, object : RestClient.AsyncRequestCallback {
            override fun onSuccess(request: RestRequest, result: RestResponse) {
                result.consumeQuietly() // consume before going back to main thread
                try {
                    println(result)
                } catch (e: java.lang.Exception) {
                    println(e)
                }
            }

            override fun onError(exception: Exception) {
                println(exception)
            }
        })

and the response I am getting in onSuccess() is

[{"errorCode":"NOT_FOUND","message":"The requested resource does not exist"}]

I am not sure where I am going wrong! Any help is appreciated :)

P.S I already checked for file and it exists fine and is accessible too(set it in an ImageView and it works fine) also the header I checked is :

{
  "method": "POST",
  "url": "\/services\/data\/v46.0\/chatter\/connect\/files\/users\/me",
  "httpHeaders": {"X-Chatter-Entity-Encoding": "false"}
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.