Versão atual:

API REST ERROR - LINHA ERP RM - VIA POST

Caros,

Segue o log abaixo do problema: Não consigo passar o objeto JSON que retorna o erro da aplicação, pois ele sempre vem com esse erro de OathProblem antes de mostrar a string JSON que contém a mensagem do ERP Linha RM . Alguém já passou por esse problema testando REST API da linha RM?



2017-12-13 12:30:36,792 ERROR [com.datasul.technology.webdesk.oauth.GenericOAuthConsumer] (default task-28) Could call the requested method: : net.oauth.OAuthProblemException: HTTP/1.1 500 Internal Server Error
URL: http://10.7.4.40:8051/rmsrestdataserver/rest/FinBancoData
oauth_signature base string: POST&http%3A%2F%2F10.7.4.40%3A8051%2Frmsrestdataserver%2Frest%2FFinBancoData&oauth_consumer_key%3D%26oauth_nonce%3D1206380801678700%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1513175436%26oauth_token%3D%26oauth_version%3D1.0
>>>>>>>> HTTP request:
POST /rmsrestdataserver/rest/FinBancoData
Content-Type: application/json
Authorization: OAuth oauth_token="", oauth_consumer_key="", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1513175436", oauth_nonce="1206380801678700", oauth_version="1.0", oauth_signature="SVeCs8RnIVILCD8Cfk3F5X7lNgc%3D"
Content-Length: 210

{"id":"245","NUMBANCO":"245","NUMEROOFICIAL":"245","DIGBANCO":null,"NOME":"TOTVS245","NOMEREDUZIDO":"TOTVS245","MASCCONTA":null,"RECCREATEDBY":null,"RECCREATEDON":null,"RECMODIFIEDBY":null,"RECMODIFIEDON":null}
<<<<<<<< HTTP response:
HTTP/1.1 500 Internal Server Error
Content-Length: 260
Content-Type: application/json; charset=utf-8
Server: Microsoft-HTTPAPI/2.0
Access-Control-Allow-Origin: *
Date: Wed, 13 Dec 2017 14:30:36 GMT

{"messages":[{"code":"0007","type":"error","detail":"Chave duplicada\r\n\r\nPossíveis causas:\r\n  - inclusão de registro cujo valor da chave primária já existe\r\n  - inclusão de registro cujo valor do índice único já existe"}],"length":0,"data":null}

Segue o script que insere o cadastro do banco no sistema ( ERP linha RM ) Cadastro de Bancos.

function beforeTaskSave(colleagueId,nextSequenceId,userList){
    if(nextSequenceId == 5){
        var users = new java.util.ArrayList();          
        //Caso a próxima atividade seja uma automática utilizar users.add("System:Auto");
        users.add("System:Auto");
        log.info("INICIO DA INTEGRACAO RM");
        var servicoURL = "http://10.7.4.40:8051/rmsrestdataserver/rest/FinBancoData";  
        var jsonString ='{"id":"'+hAPI.getCardValue("NUMBANCO")+'","NUMBANCO":"'+hAPI.getCardValue("NUMBANCO")+'","NUMEROOFICIAL":"'+hAPI.getCardValue("NUMEROOFICIAL")+'","DIGBANCO":null,"NOME":"'+hAPI.getCardValue("NOME")+'","NOMEREDUZIDO":"'+hAPI.getCardValue("NOMEREDUZIDO")+'","MASCCONTA":null,"RECCREATEDBY":null,"RECCREATEDON":null,"RECMODIFIEDBY":null,"RECMODIFIEDON":null}';
        log.info("TOTVSX 1 #####"+jsonString)
        console.log("OPA!!!");
        console.log(jsonString.length.toString());
        var myApiConsumer =  oauthUtil.getGenericConsumer("","", "", "");
        var map = new java.util.HashMap();
        map.put("Content-Length",jsonString.length.toString());
          //Insere no ERP 
        try {

            var data = myApiConsumer.postWithHeaders(servicoURL,jsonString,map);
            var objdata = JSON.parse(data);

        } catch(err) {
            throw "erro"
        }
         //log.info("TOTVSX 2 #####"+data);

         // var objdata = JSON.parse(data);
        //  var objdataJason = JSON.stringify(objdata);


    }
}

Versão (1):

Ver a versão formatada

API REST ERROR - LINHA ERP RM - VIA POST

Comentário

new question