Integrations and APIs for Service

Get Involved. Join the Conversation.

Topic

    Sebastiaan Draaisma
    javascript GET example not workingAnswered
    Topic posted October 21, 2018 by Sebastiaan DraaismaBlack Diamond: 60,000+ Points, tagged REST 
    70 Views, 8 Comments
    Title:
    javascript GET example not working
    Summary:
    Oracle Learning Subscription
    Content:

    I'm doing a javascript example in what seems an example created in 2016. I followed the instructions but I get an undefined error. The constructed URL does work in the browser. Is it possible that there is an error in the sample code (or that url calls may have changed?)

    Version:
    Aug 17
    Document:

    Best Comment

    Vlad

    Hey Sebastiaan,

    I've attached one script that does a GET request for a contact through JavaScript and one that does a PATCH (POST) request to update a contact through jQuery. Note that the update request does not return a response, so I haven't bothered with trying to show it.

    I don't think you will be able to run these tests from your computer due to CORS. If you upload it somewhere other than the .custhelp domain, make sure to update config setting PAPI_CORS_DOMAIN_LIST with the domain (e.g. http://mydomain.com).

    If you are still facing issues, turn on the browser console and let me know what error you get.

    Hope this helps,
    Vlad D

    Comment

     

    • Vlad

      Hey Sebastiaan,

      I've attached one script that does a GET request for a contact through JavaScript and one that does a PATCH (POST) request to update a contact through jQuery. Note that the update request does not return a response, so I haven't bothered with trying to show it.

      I don't think you will be able to run these tests from your computer due to CORS. If you upload it somewhere other than the .custhelp domain, make sure to update config setting PAPI_CORS_DOMAIN_LIST with the domain (e.g. http://mydomain.com).

      If you are still facing issues, turn on the browser console and let me know what error you get.

      Hope this helps,
      Vlad D

      • Ashok kumar D

        Hi Sebastiaan,

        I got this error.

        how can i solve this error?

         

        • Sebastiaan Draaisma

          This is an error related to the PAPI_CORS_DOMAIN_LIST in your configuration settings. You need to have your test page uploaded to a site (this can even be your custhelp development site) and you will then need to include the domain in this PAPI_CORS_DOMAIN_LIST

        • Vlad

          You can't run the page from your own machine due to CORS. You must upload it somewhere and set PAPI_CORS_DOMAIN_LIST to the domain you are running the script from (e.g. if you are running the script from https://ashok.mysite.com/myScript.html, you would add "https://ashok.mysite.com" to the config setting)

    • Vlad

      Attaching the update script too.

    • Sebastiaan Draaisma

      Thanks Vlad.

      I didn't got it to work yet but appreciate the provided files. Gives me something to experiment with. I will have a look at it later this week :-)

    • Vlad

      Do you get an error in the browser developer tools console?

    • Sebastiaan Draaisma

      Through a PM Vlad helped me out. As I was communicating through a different language, a language header had to be set in the code.
      Thanks again Vlad!

      xmlhttp.setRequestHeader("Accept-Language", "sv-SE");