You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cloudstack.apache.org by Mike Tutkowski <mi...@solidfire.com> on 2013/02/19 22:22:23 UTC

Question about URL Encoding for API Calls

Hi,

I've been able to make several successful API calls to CloudStack, but last
night - for the first time - I wanted to use the space character (in a
description field) for the first time.

My call failed.  I believe it was because my URL encoder converts a space
to a plus and it looks like we don't want that when coming up with the
string that's used to generate our signature:



For each field-value pair (as separated by a '&') in the Command String,
URL encode each value so that it can be safely sent via HTTP GET.
Note
Make sure all spaces are encoded as "%20" rather than "+".
I'm just using the URLEncoder class in java.net.

Does anyone know of a way for me to tell it to use %20 instead of a plus
symbol?

Thanks!

-- 
*Mike Tutkowski*
*Senior CloudStack Developer, SolidFire Inc.*
e: mike.tutkowski@solidfire.com
o: 303.746.7302
Advancing the way the world uses the
cloud<http://solidfire.com/solution/overview/?video=play>
*™*

Re: Question about URL Encoding for API Calls

Posted by John Kinsella <jl...@stratosec.co>.
Hm, that doesn't sit right with me…I'm sure there's a reason that's the case, but it sounds like a bug...

John

On Feb 19, 2013, at 1:22 PM, Mike Tutkowski <mi...@solidfire.com> wrote:

> Hi,
> 
> I've been able to make several successful API calls to CloudStack, but last
> night - for the first time - I wanted to use the space character (in a
> description field) for the first time.
> 
> My call failed.  I believe it was because my URL encoder converts a space
> to a plus and it looks like we don't want that when coming up with the
> string that's used to generate our signature:
> 
> 
> 
> For each field-value pair (as separated by a '&') in the Command String,
> URL encode each value so that it can be safely sent via HTTP GET.
> Note
> Make sure all spaces are encoded as "%20" rather than "+".
> I'm just using the URLEncoder class in java.net.
> 
> Does anyone know of a way for me to tell it to use %20 instead of a plus
> symbol?
> 
> Thanks!
> 
> -- 
> *Mike Tutkowski*
> *Senior CloudStack Developer, SolidFire Inc.*
> e: mike.tutkowski@solidfire.com
> o: 303.746.7302
> Advancing the way the world uses the
> cloud<http://solidfire.com/solution/overview/?video=play>
> *™*

Stratosec - Secure Infrastructure as a Service
o: 415.315.9385
@johnlkinsella


Re: Question about URL Encoding for API Calls

Posted by Mike Tutkowski <mi...@solidfire.com>.
Actually, this should do the trick:

java.net.URLEncoder.encode("Hello World", "UTF-8").replace("+", "%20");



On Tue, Feb 19, 2013 at 2:22 PM, Mike Tutkowski <
mike.tutkowski@solidfire.com> wrote:

> Hi,
>
> I've been able to make several successful API calls to CloudStack, but
> last night - for the first time - I wanted to use the space character (in a
> description field) for the first time.
>
> My call failed.  I believe it was because my URL encoder converts a space
> to a plus and it looks like we don't want that when coming up with the
> string that's used to generate our signature:
>
>
>
> For each field-value pair (as separated by a '&') in the Command String,
> URL encode each value so that it can be safely sent via HTTP GET.
>  Note
> Make sure all spaces are encoded as "%20" rather than "+".
> I'm just using the URLEncoder class in java.net.
>
> Does anyone know of a way for me to tell it to use %20 instead of a plus
> symbol?
>
> Thanks!
>
> --
> *Mike Tutkowski*
> *Senior CloudStack Developer, SolidFire Inc.*
> e: mike.tutkowski@solidfire.com
> o: 303.746.7302
> Advancing the way the world uses the cloud<http://solidfire.com/solution/overview/?video=play>
> *™*
>



-- 
*Mike Tutkowski*
*Senior CloudStack Developer, SolidFire Inc.*
e: mike.tutkowski@solidfire.com
o: 303.746.7302
Advancing the way the world uses the
cloud<http://solidfire.com/solution/overview/?video=play>
*™*