11 Replies Latest reply on Oct 23, 2013 1:05 AM by prashantmishra

    How can I know more about the error codes of REST API

    ratnesh

      I have been trying to use REST API (V3) from third party software[SFDC], Interestingly, the API call work fine from the REST Client (Poster,Postman etc...) but the same payload fails and gives following error when called from SalesForce. I did check needed setting at SalesForce end like 'Remote Site Setting' etc. and it looks fine.

       

      "message" : "The request could not be validated as originating from within the SBS application",

        "code" : 4026

       

       

      Thanks,

      Ratnesh

          • Re: How can I know more about the error codes of REST API
            ratnesh

            Hi Matt,

            Can you please elaborate the solution around this ?  is this really a cross-domain limitation problem ?

             

            Just wanted confirm because what I see is,

             

            GET methods are executed well, I see the response in SalesForce but POST is giving error [Status=Forbidden, StatusCode=403]

             

            Thanks,

            Ratnesh

              • Re: How can I know more about the error codes of REST API

                If you are calling into Jive using REST, then you should be using basic auth. This would be the user id / pw base64 encoded in the header. (The next release of Jive will have OAuth on the APIs so this will be easier in the near future.)

                 

                If you did this from postman, were you already logged into Jive? Try the same request from an incognito session and see what you get.

                  • Re: How can I know more about the error codes of REST API
                    ratnesh

                    Hi Mark Weitzel,

                     

                    Yes, I am using basic auth for authentication with base64 encoded. To keep the other app [SalesForce] out of scope for time being and for testing purpose I developed a sample java rest client to invoke the uri. Please find the client code below and it's getting the same error. Please note that I have removed userid : password from the code for this question

                     

                    So I was curious to know what additional thing I need to do to make Jive API understand the request/session.

                     

                    Thanks,

                    Ratnesh

                     

                    package webservicestest;
                    
                    
                    import java.net.URI;
                    
                    
                    import javax.ws.rs.core.MediaType;
                    import javax.ws.rs.core.UriBuilder;
                    
                    
                    import com.sun.jersey.api.client.Client;
                    import com.sun.jersey.api.client.ClientResponse;
                    import com.sun.jersey.api.client.WebResource;
                    import com.sun.jersey.api.client.config.ClientConfig;
                    import com.sun.jersey.api.client.config.DefaultClientConfig;
                    import com.sun.jersey.core.util.Base64;
                    
                    
                    public class RestClientJSON {
                    
                    public static void main(String[] args) {
                    
                      ClientConfig config = new DefaultClientConfig();
                         Client client = Client.create(config);
                         WebResource service = client.resource(getBaseURI());
                    
                         String auth = new String(Base64.encode("userid:password"));
                         
                         service.header("Authorization", "Basic " + auth);
                         
                      String mesgPayload = "{\"type\":\"message\",\"content\":{\"type\":\"text/html\",\"text\":\"This mesg is coming from Java client\"}}";
                    
                      ClientResponse response = service.type(MediaType.APPLICATION_JSON).post(ClientResponse.class, mesgPayload);
                    
                    
                      String output = response.getEntity(String.class);
                      System.out.println("response status "+response.getStatus());
                      System.out.println("Response ==> \n"+output);
                      }
                    
                    
                      private static URI getBaseURI() {
                      return UriBuilder.fromUri("http://cloudsquads.uat5.hosted.jivesoftware.com/api/core/v3/messages/contents/1010").build();
                      }
                    
                    
                    }
                    
                    
              • Re: How can I know more about the error codes of REST API

                Sorry for being late to the table, but I have some relevant observations that raise questions on what is being reported:

                • The reported error message (The request could not be validated as originating from within the SBS application) is coming from Jive, not from SalesForce.  This implies that the client is trying not to use Basic Authentication, but is not passing all of the cookies that Jive requires.  Using basic auth is much better (or OAuth 2 in Jive 7 / Titan).
                • The "code" : 4026 thing indicates that this is definitely not a V3 call.  This value only shows up in three circumstances:
                  • Using the extended API (from the outlook plugin) and trying to add a comment to an object that doesn't allow comments.
                  • Using a V2 call trying to share an object that cannot be shared.
                  • Using a V2 call trying to invite a user to a group they are not allowed to join.

                What is the client actually trying to do?

                • Re: How can I know more about the error codes of REST API
                  prashantmishra

                  Jared Smith-Mickelson

                  i have a similar issue for which i need help can you help me with it as well

                   

                  https://community.jivesoftware.com/thread/257491

                   

                  thanks

                  prashant