Grails 2.3.0 Restful API - PUTTING many to many relationship...

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Grails 2.3.0 Restful API - PUTTING many to many relationship...

webmediauk
Hey guys,
I've exposed my grails app as a Restful webservice. All has worked great so far until now. I have 2 models mediaOwner and country.
A media owner can operate in many countries so:

static hasMany = [ countries:Country ]

and countries can belong to many media owners so:

static belongsToMany = [ mediaOwners:MediaOwner ]

It seems like I can add and edit 1 country only by posting and putting the following XML

<mediaOwner>
<countries>2</countries>
</mediaOwner>



but I can't seem to add more than one country to a media owner? I've tried all of the below:

<mediaOwner>
<countries>
<country>2</country>
<country>3</country>
</countries>
</mediaOwner>


<mediaOwner>
<countries>2,3</countries>
</mediaOwner>


<mediaOwner>
<countries>
<country id="2" />
<country id="3" />
</countries>
</mediaOwner>


Can anyone please advise me on what I may be doing wrong?
Many Thanks
Barry
Reply | Threaded
Open this post in threaded view
|

Re: Grails 2.3.0 Restful API - PUTTING many to many relationship...

Graeme Rocher-2
could you raise a JIRA and attach an example?


On Mon, Sep 30, 2013 at 10:05 AM, webmediauk <[hidden email]> wrote:
Hey guys,
I've exposed my grails app as a Restful webservice. All has worked great so
far until now. I have 2 models mediaOwner and country.
A media owner can operate in many countries so:

*static hasMany = [ countries:Country ]*

and countries can belong to many media owners so:

*static belongsToMany = [ mediaOwners:MediaOwner ]*

It seems like I can add and edit 1 country only by posting and putting the
following XML

*<mediaOwner>
<countries>2</countries>
</mediaOwner>*


but I can't seem to add more than one country to a media owner? I've tried
all of the below:

*<mediaOwner>
<countries>
<country>2</country>
<country>3</country>
</countries>
</mediaOwner>*

*<mediaOwner>
<countries>2,3</countries>
</mediaOwner>*

*<mediaOwner>
<countries>
<country id="2" />
<country id="3" />
</countries>
</mediaOwner>*

Can anyone please advise me on what I may be doing wrong?
Many Thanks
Barry



--
View this message in context: http://grails.1312388.n4.nabble.com/Grails-2-3-0-Restful-API-PUTTING-many-to-many-relationship-tp4649734.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email





--
Graeme Rocher
Grails Project Lead
SpringSource