function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Nagaraj SVNagaraj SV 

Salesforce to OneHub Integration?

I am trying to push image from salesforce to ONEHUB .But i am getting ERROR .

Can any have idea to how to do integration with One hub.

Please help me 

Andy BoettcherAndy Boettcher

You can try using the pre-built connector from, or we can try to help with a custom APEX interface if you post your code and the ERROR you are getting.
Nagaraj SVNagaraj SV
Hi Andy,

Thank for quick response.

Vf page :

<apex:page controller="Onehubcntr">
  <apex:form >
    <apex:pageblock title="Get&Post the File in ONE HUB">
      <apex:inputText value="{!GetFile1}" title="GetFile1"/>
       <br/><apex:inputFile style="width:100%" id="fileToUpload" value="{!fileBody}" filename="{!fileName}" />
        <apex:commandbutton action="{!getSFDCSessionID}" value="PUTFILE"/>
    <iframe src="data:image/gif;base64,{!Pdffile}"></iframe> 


public class Onehubcntr{
public string fileName{get;set;}  
    public Blob fileBody{get;set;} 
    public static string attachid;     
    //Fetched from URL
    String code ;
    public String GetFile1{get;set;}
    public static String AccessToken1;
    public transient String Pdffile{get;set;}
    public Onehubcntr (){
        code = ApexPages.currentPage().getParameters().get('code') ;
        //Get the access token once we have code
        if(code != '' && code != null){
    public class WrapperAuth{
        String access_token{get;set;}
        String token_type{get;set;}
        String uid{get;set;}
        public WrapperAuth(){
    public pagereference getSFDCSessionID(){
        PageReference pg = new PageReference('') ;  
        return pg ;  
    public void getOneHubToken(){
        String tokenuri = ''+code; 
       //String tokenuri = ''+code; 
        HttpRequest req = new HttpRequest();
        Blob headerValue = Blob.valueOf('8roys5vt6f5lbbkkih2x2g50dijp3u0' + ':' + '5eoy8diy38wou36hettaj8k4enrl2gv');
        System.debug('headerValue====>>>>' + headerValue);
        String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);
        System.debug('authorizationHeader======>>>>>>' + authorizationHeader);
        req.setHeader('Authorization', authorizationHeader);
        Http h = new Http();
        String resp;
        HttpResponse res = h.send(req);
        resp = res.getBody();
        string accessToken;
        if(res.GetStatusCode()== 200){
            JSONParser parser = JSON.createParser(resp);
            String fieldName = parser.getCurrentName();
            accessToken= parser.getText();
        System.debug(' You can parse the response to get the access token ::: ' + resp);
    //public void getFile(string accessToken){}
    public void getFile(string accessToken){
        attachment a =[select id ,Name,body from attachment where id=:'00P28000001JpboEAC'];
            HttpRequest req = new HttpRequest(); 
             String username = ''; 
             String password = 'Spiderman@57'; 
             //Blob headerValue = Blob.valueOf();
            //Append Basic when we are sending userid and password
            // String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);
            // Append Bearer when we are sending userid and password
             req.setHeader('Authorization','Bearer' +accessToken);
            Http http = new Http(); 
            HTTPResponse res = http.send(req); 
Andy BoettcherAndy Boettcher

What is the error you are getting?
Nagaraj SVNagaraj SV
Satus Code :500 Internal server error
Andy BoettcherAndy Boettcher
So typically the 500 error is something coming from the remote (OneHub) end, such as your header, authorization, or payload of your callout is causing an error on the other end.  Does OneHub offer you any support or code snips to help troubleshoot?
Nagaraj SVNagaraj SV

I have sent an email to Onehub .They will reach me on monday .

I have changed  end point from to

Now it is giving Bad request Satus Code:400



Andy BoettcherAndy Boettcher
Sounds good - if they can give you some code snips/examples, that will help you a LOT.