Ning Developer Docs

hi folks,

i try to store some viewer-specific data for my gadget. code:

function saveToken(token)
{
var req = opensocial.newDataRequest();
req.add(req.newUpdatePersonAppDataRequest(opensocial.DataRequest.PersonId.VIEWER, "token", token), "data");
req.send(callback);
}

that works quite fine as long as the viewer is the same as the owner, ie when i install the gadget on my own page and then look at it (viewer = me, owner = me). but it fails when i install it at the page of another user (lets call him 'B') and then look at it (viewer = me, owner = B). what i get back is:

error code: badRequest
error message: Invalid Request was rejected.

did i miss something? is this a bug? is there a way to work around this?

thanks,
uzi

Views: 6

Replies to This Discussion

Hi Uzi,

Is there a place I can take a look at your code to investigate further?

Thanks,
- Ernie
uhm... no. this specific piece of code isnt existing anymore. but there is not much more than posted above. just attach the function to a button and pass a static token.
Hi Uzi,

From my understanding of the way newUpdatePersonAppDataRequest functions, it's mostly used to store persistent data through string value pairs on a per-user per-session basis.

If you want to take a look at the Javascript behind the Friend Map application, you can take a look at it here: newUpdatePersonAppDataRequest is used when the member enters their location and needs a JSON object stored, in the guise of a latitude-longitude pair.

http://os.ning.com/apps/friendmap/ymaps.js

Thanks,
- Ernie
Ernie -
As I mentioned in this issue, part of what I need to do is write app data on the network level so a network admin can configure the app for use. However, when I try to do so, I get the same error that uzi initially reported.

My code is here:
http://www.mailchimp.com/plugins/download/mailchimp_opensocial.xml

The code/request form line 491 to 521 is where that error is coming.

That same code works on the Member Page using OS 0.7 and I don't see anything in the 0.8 docs to indicate any major changes in the call. Let us know what you find.
Hi there, MailChimp dev!

While there hasn't been any major changes with the newUpdatePersonAppDataRequest call itself, there IS a different way you call the OWNER or VIEWER object. You can check the official 0.8 docs for more info, but you might want to look into changing:

req.add( req.newFetchPersonAppDataRequest(opensocial.DataRequest.PersonId.VIEWER, MC_CFG), 'mccfg');
req.send(cb_cb_saveSettings);

to:

var params = {};
params[opensocial.IdSpec.Field.USER_ID] = opensocial.IdSpec.PersonId.VIEWER;
params[opensocial.IdSpec.Field.GROUP_ID] = opensocial.IdSpec.GroupId.SELF;
var idspec = opensocial.newIdSpec(params);
req.add(req.newFetchPersonAppDataRequest(idspec, 'MC_CFG'),'mccfg');
req.send(cb_cb_saveSettings);

Note that the above code ONLY applies to OpenSocial 0.8 apps and not 0.7 apps which are used on Profile-based Applications.

Let me know if you're encountering difficulties.

Thanks, Ernie
Ernie, I completely pasted in the wrong link.

This is the correct one:
http://www.mailchimp.com/plugins/download/mailchimp_opensocial_net.xml

The code there is pretty close to what you listed, but skipped the Group_Id setting. Currently I have Owner instead of Viewer in there, but I've tried them both.
Hi there,

I noticed you that your init() function still makes a direct reference to opensocial.IdSpec.PersonId.OWNER without declaring the opensocial.newIdSpec first. Could that be what's causing an issue?

If you're still having problems I can look at this in a bit more detail.

Thanks, Ernie
I think you were looking at my "ning.main" section and not the "canvas" section since I am using the new idSpec form there. Once I get the canvas working I'll deal with the ning.main section.

Also, the error is not coming until I hit the update code mentioned previous from lines 491 - 521. The error details returned are still the same as what uzi initially reported. Also, I have tested this this morning and the updates over the weekend appear to have no affect.

If you can't report a bug, could you possibly just provide a very simple piece of working code that saves & retrieves data at the network level?
Hi MailChimp API,

OK... I just tried some code of my own and I'm having some issues now as well. Thanks for letting me know; I'm escalating this issue immediately to our team.

Thanks,
- Ernie
Hi there,

Just want to follow-up really quickly: I think we're beginning to figure out what's going on, but before I try to explain the situation, can you verify that the persistant data that's you're trying to store are configurable options specifically to the network as a Network Creator?

Will there be any cases where members of a network will have to be entering data that will be stored by newUpdatePersonAppDataRequest? If so, in which views?

Sorry for the flux of questions; because moving Applications from the Profile view to the Main view go off the specifications sheet, we're trying to address the challenges that go with it.

Thanks,
- Ernie
Yes, the configuration options are specific to the network and need to be generally accessible to all users (authenticated or not) for the application to function correctly.

In my case I do not need store any user-centric or entered data for my application, but I can see others needing to do so, so you may want to consider trying to support that.
I have a code :
function request() {
var req = opensocial.newDataRequest();

key = "k1";
text = "asdasd";

req.add(req.newUpdatePersonAppDataRequest(opensocial.DataRequest.PersonId.VIEWER, key, text), "set_data");
req.send(set_callback);
};

When I try to save data from OWNER account, data is saved ok. When i save data from VIEWER account, script returns "[{"error":{"message":"badRequest: Invalid Request was rejected.","code":400}}]".
Please help me to determine what I am doing wrong.

RSS

© 2026   Created by Ning Developer Admin.   Powered by

Badges  |  Report an Issue  |  Terms of Service