Skip to content
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

How send a complex object via the API ? #75

Open
afaucogney opened this issue Jun 1, 2015 · 6 comments
Open

How send a complex object via the API ? #75

afaucogney opened this issue Jun 1, 2015 · 6 comments
Labels

Comments

@afaucogney
Copy link

How can I implement saving a complex object from Android to the Server.
The object is defined as object type on the server, and on Android is a Hashmap of subObjects, which are itself hashmaps.

@bajtos
Copy link
Contributor

bajtos commented Jun 2, 2015

What have you tried so far? What were the results?

@bajtos bajtos added the triage label Jun 2, 2015
@afaucogney
Copy link
Author

Sorry, I didn"t get notified you answer me....

I get an error : "Unprocessable Entity".
I have a Objet that is composed with subObjects that contains HashMaps members.

I deal with the code until the Object.toMap() return a JSON like file..... but still something wrong. What are the rules to extends Model with it own Object, especially when there is composition pattern.

@afaucogney
Copy link
Author

When I logged Obj.toMap().toString(), I get

{wineColor=1, id=Bouche:Equilibre, wineType=1, oenoLevel=1, instruction={what=Pas d information, how=Pas d information, why=Pas d information}, tripTag=Bouche:Equilibre}

When I update (replace = by : and adding ") this text to {
"wineColor":1,
"id":"Bouche:Equilibre",
"wineType":1,
"oenoLevel":1,
"instruction":
{
"what":"Pas d information",
"how":"Pas d information",
"why":"Pas d information"
},
"tripTag":"Bouche:Equilibre"}

and I put in the Loopback Explorer, this work with the API, but not from the Client

@afaucogney
Copy link
Author

@bajtos any news or comment to help ?

@bajtos
Copy link
Contributor

bajtos commented Jun 19, 2015

The SDK uses JsonUtil to convert from Java objects to JSON representation. See this unit-test for an example what is the correct way of creating nested object structures.

Try to enable ADB debug logs, the SDK is logging all request data via Log.d (source code). That way you should see what JSON was produced from your data.

I am afraid I don't have much time to investigate this. It would help me a lot if you could create a standalone app (LoopBack server, Android client) that I could run on my machine to reproduce the problem.

@jjhesk
Copy link

jjhesk commented Jul 22, 2016

I would make it one flatten into string then using the string and pass it into the url. Using Gson to flatten the object and parse it into the url.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants