Integrations and APIs for Service

Get Involved. Join the Conversation.

Topic

    Sathya Rajendran
    REST API: OSC-CREST-00008Answered
    Topic posted May 6, 2019 by Sathya RajendranGold Medal: 3,500+ Points, tagged REST 
    108 Views, 6 Comments
    Title:
    REST API: OSC-CREST-00008
    Content:

    Hello All,

    When create contact using rest api i am getting below error. And it throw error after refresh only in live it is working perfectly. Any idea why it is?

    {
        "type": "https://mysite-int--tst2.custhelp.com/services/rest/connect/exceptions/OSC-CREST-00008",
        "title": "An internal error has occurred",
        "status": 500,
        "detail": "Cannot save/update: Contact(ID=0): \nDB API Error\n",
        "instance": "Unexpected internal problem: %s",
        "o:errorCode": "OSC-CREST-00008"
    }

    Best Comment

    Wouter Willemse

    Maybe a silly idea, but we're seeing a similar issue on creating contacts/incidents via API on a testsite which is a sparse clone. On a full clone, it works without issue.

    If you check the logs, under Error Log, you will find more detail on the error. In our case it indicates a violation in creating unique IDs in the DB, so it seems the sparse clone creation breaks something there.

    Comment

     

    • Lakshay Bhalla

      Hi Sathya,

      Can you please post the piece of code you are using to save the contact for analysis?

      Thanks

    • Sathya Rajendran

      Hi Lakshay,

      See my below code.

      function createContactRecord(sessionToken,email,fname,lname,custid,Brand)
      {    
          var obj=[];      
              obj.push({
                  name :{
                      first: fname,
                      last: lname
                  },
                  emails:{
                      addressType:{
                          id: 0
                      },
                      address:email
                  },
                  customFields:{
                      c:{
                      cf_session_brand:{
                           lookupName: Brand
                      },
                      cf_session_market:{
                               lookupName: SessionMarket
                          }
                  }
                  }
               });
                       
          return $.ajax({
                url: globalContext.getInterfaceServiceUrl('rest')+'/connect/v1.3/contacts',
                method: "POST",
                headers:{'Authorization':'Session '+sessionToken},
                data: JSON.stringify(obj),
                dataType: "json"
              });
      }

      • Lakshay Bhalla

        Sathya,

        It appears to be piece of code being used in Some Extension. Are you Creating an Extension to create Contact? Or Could you explain the requirement if possible?

        Thanks

      • Rajan Davis

        I think you should be able to stringify the object literal without pushing it into an array.

        Also, I think your issue comes from setting the address type to an id of 0. If you POST the JSON without it being in an array, I think this problem will go away.

        Try this:

        function createContactRecord(sessionToken,email,fname,lname,custid,Brand)
        {    
            var obj = {
                name : {
                    first: fname,
                    last: lname
                },
                emails:{
                    addressType:{
                        id: 0
                    },
                    address:email
                },
                customFields:{
                    c:{
                         cf_session_brand:{
                            lookupName: Brand
                         },
                         cf_session_market:{
                            lookupName: SessionMarket
                         }
                     }
                 }
            };
        
            return $.ajax({
                  url: globalContext.getInterfaceServiceUrl('rest')+'/connect/v1.3/contacts',
                  method: "POST",
                  headers:{'Authorization':'Session '+sessionToken},
                  data: JSON.stringify(obj),
                  dataType: "json"
            });
        }
        
    • Wouter Willemse

      Maybe a silly idea, but we're seeing a similar issue on creating contacts/incidents via API on a testsite which is a sparse clone. On a full clone, it works without issue.

      If you check the logs, under Error Log, you will find more detail on the error. In our case it indicates a violation in creating unique IDs in the DB, so it seems the sparse clone creation breaks something there.

    • Sathya Rajendran

      Hi Wouter,

      Solved by raising support to oracle as the issue same as you told during test site refresh.