Integrations and APIs for Service

Get Involved. Join the Conversation.

Topic

    Sathya Rajendran
    Error Code "OSC-CREST-00017" using REST APIAnswered
    Topic posted October 25, 2018 by Sathya RajendranGold Medal: 3,500+ Points, last edited October 25, 2018, tagged REST 
    74 Views, 7 Comments
    Title:
    Error Code "OSC-CREST-00017" using REST API
    Content:

    Hi All,

    I am using rest api to retrieve contact based on the contact email address, My code works well for one interface which is EN-US but give error OSC-CREST-00017 for other interface which is FR.

     

    var ajaxUrl = globalContext.getInterfaceServiceUrl('rest') + "/connect/v1.3/queryResults/?query=SELECT id FROM contacts WHERE Emails.EmailList.Address='"+ EmailAddress + "'";
    //alert(ajaxUrl);
                return $.ajax({
                type: "GET",
                async: false,
                url: ajaxUrl,
                beforeSend: function (xhr) { xhr.setRequestHeader("Authorization", "Session " + sessionID); }
                });
     
    Error:  "type": "https://Mysite.custhelp.com/services/rest/connect/exceptions/OSC-CREST-00017",
        "title": "Une langue non prise en charge a été demandée",
        "status": 400,
        "detail": "This interface uses fr-FR language which does not match with requested language of 'en-US,en;q=0.9'",
        "instance": "https://mysite.custhelp.com/services/rest/connect/v1.3/contacts/456",
        "o:errorCode": "OSC-CREST-00017"

    Best Comment

    Vlad

    xhr.setRequestHeader("Accept-Language", "fr-FR");

    Comment

     

    • Vlad

      xhr.setRequestHeader("Accept-Language", "fr-FR");

    • Sebastiaan Draaisma

      Yeah, I just wanted to comment that :-D
      An alternative that I figgered out (if you will be using this from different languages) is to have it dynamically

      var language = window.navigator.userLanguage || window.navigator.language;
      xhr.setRequestHeader("Accept-Language", language);

      • Vlad

        So if you have a French interface, you must perform the request using the French language in the header. If you use the browser's language and it's not French, it will fail.

        One way to implement window.navigator.language is to get the language like this and then check in your code if you have any interfaces "listening" on that language. If yes, set the appropriate endpoint. If no, just hard code a language like English.

    • Vlad
      That would use the browser language, which is the problem in the first place if I understood right ^_^
    • Sathya Rajendran

      Hi Vlad and Sabaastian,

      Error resolved, and i window.navigator.language not worked, 

      I used globalContext.getLanguage(); to get my interface language and it works perfectly .

      Thanks a lot