New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supply default RequestBody converters for primitives? #763

Closed
b22n opened this Issue Feb 27, 2015 · 7 comments

Comments

3 participants
@b22n

b22n commented Feb 27, 2015

Retrofit 1.9.0 / OkHttp 2.2.0
Using default GsonConverter

@Multipart
@PUT("/xxxx")
void method (
   @Part("idx") long idx,
   @Part("image") TypedFile image
);

Request Header:
Content-Type: multipart/form-data; boundary=9bf70ec9-6823-4209-ac75-933a931b8baf
Content-Length: 673890
--9bf70ec9-6823-4209-ac75-933a931b8baf
Content-Disposition: form-data; name="idx"
Content-Type: application/json; charset=UTF-8
Content-Length: 3
Content-Transfer-Encoding: binary
244

Expectation: the body param should be encoded in json format or Content-Type should be the 'text/plain'.

@JakeWharton

This comment has been minimized.

Show comment
Hide comment
@JakeWharton

JakeWharton Feb 27, 2015

Collaborator

long is a primitive, so it has no structure in JSON format. If the object was not a primitive you would see the normal JSON structure. You can achieve text/plain easily by using a String instead for the parameter type instead.

Collaborator

JakeWharton commented Feb 27, 2015

long is a primitive, so it has no structure in JSON format. If the object was not a primitive you would see the normal JSON structure. You can achieve text/plain easily by using a String instead for the parameter type instead.

@b22n

This comment has been minimized.

Show comment
Hide comment
@b22n

b22n Mar 2, 2015

the wrapper class Long is also encoded with plain text.
and I think, if primitive types have no structure in JSON format, the Content-Type header shouldn't be the 'application/json'.

b22n commented Mar 2, 2015

the wrapper class Long is also encoded with plain text.
and I think, if primitive types have no structure in JSON format, the Content-Type header shouldn't be the 'application/json'.

@JakeWharton

This comment has been minimized.

Show comment
Hide comment
@JakeWharton

JakeWharton Mar 14, 2015

Collaborator

Maybe for 2.0.

Collaborator

JakeWharton commented Mar 14, 2015

Maybe for 2.0.

@sigod

This comment has been minimized.

Show comment
Hide comment
@sigod

sigod Oct 15, 2015

I just want to point out that 244 is a valid JSON.

sigod commented Oct 15, 2015

I just want to point out that 244 is a valid JSON.

@JakeWharton

This comment has been minimized.

Show comment
Hide comment
@JakeWharton

JakeWharton Oct 15, 2015

Collaborator

It isn't.

Collaborator

JakeWharton commented Oct 15, 2015

It isn't.

@sigod

This comment has been minimized.

Show comment
Hide comment
@sigod

sigod Oct 26, 2015

Yes, it is.

Early versions of JSON (such as specified by RFC 4627) required that a valid JSON "document" must consist of only an object or an array type—though they could contain other types within them. This restriction was removed starting with RFC 7158, so that a JSON document may consist entirely of any possible JSON typed value.

sigod commented Oct 26, 2015

Yes, it is.

Early versions of JSON (such as specified by RFC 4627) required that a valid JSON "document" must consist of only an object or an array type—though they could contain other types within them. This restriction was removed starting with RFC 7158, so that a JSON document may consist entirely of any possible JSON typed value.

@JakeWharton JakeWharton changed the title from Multipart content-type encoding problem to Default RequestBody converters for primitives. Nov 19, 2015

@JakeWharton JakeWharton changed the title from Default RequestBody converters for primitives. to Supply default RequestBody converters for primitives? Nov 19, 2015

@JakeWharton

This comment has been minimized.

Show comment
Hide comment
@JakeWharton

JakeWharton Nov 19, 2015

Collaborator

@sigod Ew, that's dumb. Thankfully it's not Retrofit's problem but the serialization library being used.

Renamed this issue to correctly reflect what it's asking for.

Collaborator

JakeWharton commented Nov 19, 2015

@sigod Ew, that's dumb. Thankfully it's not Retrofit's problem but the serialization library being used.

Renamed this issue to correctly reflect what it's asking for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment