• sidb
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 2
    Replies

Hi

I am writing a JSON Parser Apex class and following the documentation. I get the following error:
Error: YelpAPIController Compile Error: Illegal assignment from JSONParser to JSONParser at line 56 column 10

Here is my code:

public class JSONParserUtil {
@future(callout=true)
public static void parseJSONResponse() {
Http httpProtocol = new Http();
// Create HTTP request to send. 

HttpRequest request = new HttpRequest();
// Set the endpoint URL. 

String endpoint = 'http://www.cheenath.com/tutorial/sfdc/sample1/response.php';
request.setEndPoint(endpoint);
// Set the HTTP verb to GET. 

request.setMethod('GET');
// Send the HTTP request and get the response. 

// The response is in JSON format. 

HttpResponse response = httpProtocol.send(request);
System.debug(response.getBody());

// Parse JSON response to get all the totalPrice field values. 

JSONParser parser = JSON.createParser(response.getBody());
Double grandTotal = 0.0;
while (parser.nextToken() != null) {
if ((parser.getCurrentToken() == JSONToken.FIELD_NAME) &&
(parser.getText() == 'totalPrice')) {
// Get the value. 

parser.nextToken();
// Compute the grand total price for all invoices. 

grandTotal += parser.getDoubleValue();
}
}
system.debug('Grand total=' + grandTotal);
}
}




I am not sure what wrong here. The error is not explaining anything.

Thanks
Sid


  • October 15, 2011
  • Like
  • 0

Hi

 

I am using eclipse to write a new apex trigger.

 

 

 

and I am getting the attached error message. Any help would be great.

 

I am getting error message. An expected error has occurred.

trigger RequestLineItem_AfterInsert on Request_Line_Item__c (after insert) {
	for(Request_Line_Item__c reqli: trigger.new){
		List<Product_Group__c> pg = [Select p.id, p.Technical_Owner__c, p.Business_Owner__c From Product_Group__c p where Product_Group__c =
										:reqli.Product_Group__c LIMIT 1];
	
		//reqli.Product_Group_Object__c = pg.get(0).id;
		update reqli;
		
	
	}
}

 

 

  • May 27, 2010
  • Like
  • 0

I am trying to expose a apex webservice publically without authentication.

 

-          I have created the webservice and tested with session_id.

-          I added the apex class to the sites profile

-          I made sure the object is available in the profile with all permissions.

 

I am still getting invalid session id.

 

Anything else?

 
  • December 16, 2009
  • Like
  • 0

Hi

 

I have a page where I have used the "connection.js" to Login into a Salesforce instance.

 

But I am receiving errors when I try to do this.

 

When I host it from a Local Server or on a Salesforce Sites page, I get the error:

 

[Exception... "Access to restricted URI denied"  code: "1012" nsresult: "0x805303f4 (NS_ERROR_DOM_BAD_URI)"  location: "https://na6.salesforce.com/soap/ajax/16.0/connection.js Line: 594"]

 

Can anyone tell me why this error occurs? And what should be done for successful Login?

 

I have provided my code below. Its a simple JS code that calls the Login method.

 

 

================ CODE ==============================

 

<HTML>
<HEAD>

<script src="https://na6.salesforce.com/soap/ajax/16.0/connection.js" ></script>

<script type="text/javascript" >

function logincall()
{

    try{
   
    sforce.connection.serverUrl = 'http://www.salesforce.com';
   
    var usrname = document.getElementById('userid').value;
    var passwrd = document.getElementById('passid').value;

    if(usrname == null || usrname == '' || passwrd == null || passwrd == '')
    {
        alert('Please enter Username AND Password');
        return;
    }
   
    var result = sforce.connection.login(usrname, passwrd);

    alert("Logged in with session id " + result.sessionId);
    }
    catch(error)
    {
        alert(error);
       
    }

}

</script>

</HEAD>

<BODY>


To test logging into a Salesforce Instance using the connection.js "login" call


<table>
        <tr>
            <td>Username</td>
            <td><input type="text" id="userid" value="" /></td>
        </tr>
        <tr>
            <td>Password</td>
            <td><input type="password" id="passid" value="" /></td>
        </tr>

</table>


    <input type="button" value="Login" onclick="logincall();" />

</BODY>

</HTML>

 

================ CODE ==============================

  • November 09, 2009
  • Like
  • 0
Going through the Force.com Workbook and on pg 31, trying to create an Apex Trigger by Right clicking on my project folder and trying to select New Apex Trigger, but I don't have that option. Rather I get the option to create a new Project, Folder, File, Example or Other.

Same thing when I tried to Create a New Application. Also, when I right click on my project and select Properties, I don't have an option to download the latest metadata changes on the server. I went and updated by force.com ide to the latest by going to Help and Software Updates and following the directions on this website for upgrading the ide.

Thanks for your help in advance.

Johns