+ Start a Discussion
Rakesh M 20Rakesh M 20 

Hi All, can anyone help me to find what is the error in this piece code please..

@RestResource(urlMapping='/v1/BookDetails/')
global class bookManager 
{
@httpGet
global static Book__c doGetBook()
{
    Book__c book = new Book__c();
    Map<String,String> paramsMap = RestContext.request.params;
    String bookId = paramsMap.get('Id');
    book = [select Id, Name, Price__c from Book__c where Id IN =: bookId]; // getting sytax error in this line
    return book;
}
}
Best Answer chosen by Rakesh M 20
Andrew GAndrew G
your have both equals (=) and IN in your SELECT statement.  Need one or the other
so try:
book = [select Id, Name, Price__c from Book__c where Id = : bookId];

regards
Andrew​​​​​​​

All Answers

ANUTEJANUTEJ (Salesforce Developers) 
Hi Rakesh,

Can you state the error you are getting in the above code so as to look further and respond back.

Looking forward to your response.

Thanks.
Rakesh M 20Rakesh M 20
Hi  ANUTEJ,
Following are the errors for that line 
1)  Unexpected token '='.
2)  Unexpected token ':'.
3)  Extra ';', at ']'.
4)  Expression cannot be assigned
5)  Expression cannot be a statement.


please look onto this
Andrew GAndrew G
your have both equals (=) and IN in your SELECT statement.  Need one or the other
so try:
book = [select Id, Name, Price__c from Book__c where Id = : bookId];

regards
Andrew​​​​​​​
This was selected as the best answer
Rakesh M 20Rakesh M 20
Thanks Andrew G
Its working now..