400 Bad Request using jQuery plugin

Comments

5 comments

  • Avatar
    Itay Taragano

    Hi David,

    It seems that the JSON you pass into data-form-data is double-html-escaped. Can you please html-escape it only once and try again?
    It should look something like:

    {"timestamp":1436467258,"callback":"https://c.cs8.visual.force.com/apex/CARY_UploadImage","signature":"bd8b04aa7a86e60178243cbce85e706cd80d2571","api_key":"782454775414318"}
    
    0
    Comment actions Permalink
  • Avatar
    David Padilla

    Hello Itay,

    I have changed it, but I still get the same 400 Bad Request: this is how data-form-data looks like now:
    {"timestamp":1436597748,"callback":"https://c.cs8.visual.force.com/apex/CARY_UploadImage","signature":"2f940e384bf3f2816c4c187b72f43a4d5b394fbb","api_key":"782454775414318"}

    Just for the record, I am using Salesforce.com in the backend and this is how I generate the signature:

    cloudinary_timestamp=String.valueOf(Integer.valueOf(System.NOW().getTime()/1000));
    String myData = 'public_id=CldinaryImg&timestamp='+cloudinary_timestamp+cloudinary_api_secret;
    Blob hash = Crypto.generateDigest('SHA1',Blob.valueOf(myData));
    String hexDigest = EncodingUtil.convertToHex(hash);
    cloudinary_signature = hexDigest;

    0
    Comment actions Permalink
  • Avatar
    Itay Taragano

    It seems that the data-form-data is now partially html-escaped and partially isn't.

    Can you please make sure it is all escaped once and try this again?

    You can use the code snippets from our SalesForce integration KB.

    0
    Comment actions Permalink
  • Avatar
    David Padilla

    Hi Itay,
    sorry, for some reason when I copy&paste the data-form-data here, the escaped strings are modified:
    This is the data-form-data (hope it will not be modified when I submit the answer):

    &
    quot;timestamp&
    quot;:1436767137,&
    quot;callback&
    quot;:&
    quot;https://c.cs8.visual.force.com/apex/CARY_UploadImage",&
    quot;signature&
    quot;:&
    quot;cd6280fd3dee31fba03a22b54bd5637ca0bb4646&
    quot;,&
    quot;api_key&
    quot;:&
    quot;782454775414318&
    quot;

    I am using Salesforce, but I do not want to upload pictures from the salesforce server. Instead, I'd like to use jQuery to upload directly from the page without having to pass the info to the server.

    0
    Comment actions Permalink
  • Avatar
    Itay Taragano

    If you could please open a Support ticket and attach the full generated HTML file there, I'll be happy to take a deeper look at it.

    0
    Comment actions Permalink

Please sign in to leave a comment.