I keep getting the error,
"You must specify a key to access the Zotero API."
I have tried what I think are all possible ways to specify my API key
as described in the API documentation, to no avail.
Are there any explicit code examples available?
Thanks,
Rich Lent
> I am using the ASIHTTPRequest library in an attempt to access the
> Zotero API via GET, POST, etc.
>
> I keep getting the error,
>
> "You must specify a key to access the Zotero API."
You must add a parameter 'key' containing a valid API key to the request. See http://www.zotero.org/support/dev/server_api/read_api#authentication
>
> I have tried what I think are all possible ways to specify my API key
> as described in the API documentation, to no avail.
>
> Are there any explicit code examples available?
Yes. The authentication document to which I link above provides a link to creating keys manually and a link to php code that shows how keys are generated with OAuth. If you want an example using Objective C you can take a look at ZotPad (https://github.com/mronkko/ZotPad).
What are you developping? I am fairly sure that a better option than using ASIHTTPRequest woudl be to just initialize NSXMLParser with an URL. This will result in less code and I also believe that it allows you to start parsing the response as it arrives instead of waiting for the data transfer to complete.
Here is an example from ZotPad
-(NSArray*) retrieveLibrariesFromServer{
//Retrieve all libraries from the server
NSURL *fileURL = [NSURL URLWithString:[NSString stringWithFormat:@"https://api.zotero.org/users/%@/groups?key=%@",_userID,_oauthkey]];
NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:fileURL];
ZPServerResponseXMLParser* parserDelegate = [[ZPServerResponseXMLParser alloc] init];
[parser setDelegate: parserDelegate];
[parser parse];
return [parserDelegate results];
}
If you are developing for iPhone/iPad, I would like to hear more about your project. Also if you plan to release your code as open source it might make sense to merge your project with ZotPad or the other way around to avoid duplicate work.
MIkko
>
> Thanks,
>
> Rich Lent
>
> --
> You received this message because you are subscribed to the Google Groups "zotero-dev" group.
> To post to this group, send email to zoter...@googlegroups.com.
> To unsubscribe from this group, send email to zotero-dev+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/zotero-dev?hl=en.
>
On Nov 23, 1:34 am, Rönkkö Mikko <mikko.ron...@aalto.fi> wrote:
> On Nov 22, 2011, at 22:56, Richard Lent wrote:
>
> > I am using the ASIHTTPRequest library in an attempt to access the
> > Zotero API via GET, POST, etc.
>
> > I keep getting the error,
>
> > "You must specify a key to access the Zotero API."
>
> You must add a parameter 'key' containing a valid API key to the request. Seehttp://www.zotero.org/support/dev/server_api/read_api#authentication
Thanks for your reply Mikko. At this point I'm just trying to learn
the Zotero API to see what's possible in an iOS app. I'm ok with the
read API but am having trouble with how to specify a key for the write
API, so that items could be added and edited to an online library.