Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android:Retrofit URL Path Without "/"

So I am actually trying to do a PUT with a TypedByteArray as my body. I am interacting with an Azure server, so the first step is to

  1. Make a POST call with my image metadata and I get back a URL (say URL_PUT)

  2. I have to make a PUT request to that URL_PUT (from step 1), so my retrofit singleton interface function looks like:

    public interface ImageInterface {

         @PUT("/{nothing}")
         Response uploadBlob(@Body TypedByteArray byteArray, 
             @Header("Content-Length") String byteArrayLength, 
             @Path(value="nothing",encode=false) String nothing);

    }

But I get an error saying that URL path must start with an "/" when I pass "" for nothing. For the above function I tried passing an empty string, but to no avail.

So basically I just want to use retrofit with an endpoint but no path/balnk path for PUT. IS there any way to do this ?

like image 378
uLYsseus Avatar asked Nov 09 '14 19:11

uLYsseus


1 Answers

How about splitting the URL_PUT?

In example you have http://example.com/path/more/path/image.jpg

You split it in 2 strings: - http//example.com - /path/more/path/image.jpg

Then you get rid of the first "/" of the 2nd Stirng. Then similar as you had:

public interface ImageInterface {

     @PUT("/{second-string}")
     Response uploadBlob(@Body TypedByteArray byteArray, 
         @Header("Content-Length") String byteArrayLength, 
         @Path(value="second-string",encode=false) String secondString);

}

Then on your client use string 1 with this interface. And send string 2 as a parameter. I guess this should work.

(Sorry I typed this so fast, I'm on the move)

like image 78
Alberto Garrido Avatar answered Oct 13 '22 00:10

Alberto Garrido