• Yogesh_Rankawat.ax397
  • NEWBIE
  • 0 Points
  • Member since 2008

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

Hi All

 

I have written a trigger as below

trigger testChangeOwnerTrigger on Case (before insert) { for(Case newCase : Trigger.New){ newCase.OwnerId ='005R0000000IufqIAC'; } }

 

Here the 'created use'r and 'new owner user' has the same profile.

 

This trigger is working correctly when I create case with System Administrator profile user, but when create case with other profile user then it throw an error "Insufficient Privileges You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary. Click here to return to the previous page "

 

I checked the profile & it has all data modification permissions.

 

Any idea?

 

Thanks

 


 

Hi

I am using following Apex class in Salesforce to create HIT using REST of Amazon Mechanical Turk Webservice :

---------------------------------------------------------------------------------------------------

Code:
public class DemoHIT {
  public DemoHIT(){
    
  }
 
  public string signature( string op, Datetime now, string securityKey) {
     String formattednow = now.formatGmt('yyyy-MM-dd')+'T'+now.formatGmt('HH:mm:ss')+'.'+now.formatGMT('SSS')+'Z';           
     String canonical = 'AWSMechanicalTurkRequester'+op+formattednow;
     Blob bsig = Crypto.generateMac('HmacSHA1', Blob.valueOf(canonical), Blob.valueOf(securityKey));          
     return EncodingUtil.base64Encode(bsig);
  }
        
   
  public PageReference CreateHITFromREST(){
   try{
     
      string AWSAccessKeyId = '0946QXXMCPG7HW9FJTG2';
      string SecretAccessKey  = 'R/nrFePFroQL4uzgzLi7iZOKRSzCN1Sg7coZRUpl';
      string op = 'GetAccountBalance';
      DateTime Timestamp = system.now();
      String Signature = signature(op, Timestamp, SecretAccessKey);
      
      String formattednow = Timestamp.formatGmt('yyyy-MM-dd')+'T'+Timestamp.formatGmt('HH:mm:ss')+'.'+Timestamp.formatGMT('SSS')+'Z';           
        
      string ques = '<Question><QuestionIdentifier>my_question_id</QuestionIdentifier><DisplayName>My Question</DisplayName><IsRequired>true</IsRequired><QuestionContent><Title>The Next Move</Title></QuestionContent><AnswerSpecification><FreeTextAnswer><Constraints><IsNumeric minValue="100" maxValue="999"/><Length minLength="3" maxLength="3"/></Constraints></FreeTextAnswer></AnswerSpecification></Question>';
      ques = EncodingUtil.urlEncode(ques,'UTF-8');   
      Signature =  EncodingUtil.urlEncode(Signature,'UTF-8');    
      string url = 'http://mechanicalturk.sandbox.amazonaws.com/onca/soap—Service=AWSMechanicalTurkRequester&AWSAccessKeyId=' + AWSAccessKeyId + '&Version=2008-08-02&Operation=CreateHIT&Signature=' + Signature + '&Timestamp=' + formattednow + '&Title=Location%20and%20Photograph%20Identification&Description=Select%20the%20image%20that%20best%20represents&Reward.1.Amount=5&Reward.1.CurrencyCode=USD&Question=' + ques + '&AssignmentDurationInSeconds=30&LifetimeInSeconds=604800&Keywords=location,%20photograph,%20image,%20identification,%20opinion' ;     
       


      Http h = new Http();
      HttpRequest req = new HttpRequest();
      req.setEndpoint(url);
      req.setMethod('GET');

      HttpResponse res = h.send(req);
      system.debug('-------------body---');
      System.debug(res.getBody());
      system.debug('----------------');

     }
   catch(exception ex){
    ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.WARNING,ex.getMessage()));
   }
   return null;
  }
    
}

 
---------------------------------------------------------------------------------------------------
But it gives following response in system log as "AWS.BadClaimsSupplied" :

<CreateHITResponse><OperationRequest><RequestId>e643f098-4b44-4121-aab7-988b12d23668</RequestId><Errors><Error><Code>AWS.BadClaimsSupplied</Code><Message>The specified claims are invalid.</Message></Error></Errors></OperationRequest></CreateHITResponse>


Can any body help me to fix this problem?

Thanks



Message Edited by Yogesh_Rankawat on 01-16-2009 04:21 PM