Skip to main content

Hi, I want to send sessionId information received by Authontication to the action part and I wrote these codes:

 

Authontication code:

 

const data = bundle.authData.username + ':' + bundle.authData.password;
const base64Auth = btoa(data);

const loginOptions = {
  url: 'http://deneme/deneme/api/v1.0/login?authorization=' + base64Auth,
  method: 'POST',
  headers: {},
  params: {},
  body: {}
};

return z.request(loginOptions)
  .then((response) => {
    response.throwForStatus();
    const sessionId = response.json.SessionId;

    // Set sessionId as authData
    return {
      sessionId: sessionId
    };
  });

 

Action code:

 


const sessionId = bundle.authData.sessionId;

const ticketDescription = bundle.inputData.TicketDescription;
const array = ticketDescription.split("sevgili ");
var description = array/1];

const nameArray = description.split(" ");
const descriptionName=nameArrayd0];


 
const options = {
  url: 'http://deneme/deneme/api/v1.0/tickets?SessionId='+sessionId,
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/json',
    'X-USERNAME': bundle.authData.username
  },
  body: {
    TicketDescription: descriptionName ,
    TicketState: {
      Oid: '33a22cef-55fa-468b-9e5b-bfe2450327d7',
      TicketStateDescription: 'Başlangıç'
    }
  }
};


return z.request(options)
  .then((response) => {
    response.throwForStatus();
    const results = response.json;

    // You can do any parsing you need for results here before returning them

    return results;
  });
 

But I'm getting this error:

The app returned "The request is invalid.". What happened (You are seeing this because you are an admin): Stack trace: ResponseError: {"status":500,"headers":{"content-type":"application/json; charset=utf-8","retry-after":null},"content":"{\"Message\":\"The request is invalid.\",\"ModelState\":{\"ServerError\":e\"Exception : Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).\"]}}","request":{"url":"http://democrm.logo.com.tr/LogoCrmRest/api/v1.0/tickets?SessionId=undefined"}} at _throwForStatus (/var/task/node_modules/zapier-platform-core/src/http-middlewares/after/prepare-response.js:13:11) at Object.outResp.throwForStatus (/var/task/node_modules/zapier-platform-core/src/http-middlewares/after/prepare-response.js:68:5) at throwForStatusMiddleware (/var/task/node_modules/zapier-platform-core/src/http-middlewares/after/throw-for-status.js:5:14) at Object.<anonymous> (/var/task/node_modules/zapier-platform-core/src/middleware.js:80:37) From previous event: at /var/task/node_modules/zapier-platform-core/src/middleware.js:77:26 at Array.reduce (<anonymous>) at afterMiddleware (/var/task/node_modules/zapier-platform-core/src/middleware.js:76:21) at Object.<anonymous> (/var/task/node_modules/zapier-platform-core/src/middleware.js:94:18) From previous event: at Object.<anonymous> (/var/task/node_modules/zapier-platform-core/src/middleware.js:92:10) From previous event: at /var/task/node_modules/zapier-platform-core/src/middleware.js:89:45 at /var/task/node_modules/zapier-platform-core/src/tools/create-lambda-handler.js:212:18 at bound (node:domain:433:15) at runBound (node:domain:444:12) at processImmediate (node:internal/timers:466:21) at process.topLevelDomainCallback (node:domain:161:15) at process.callbackTrampoline (node:internal/async_hooks:128:24) From previous event: at Domain.<anonymous> (/var/task/node_modules/zapier-platform-core/src/tools/create-lambda-handler.js:196:10) at Domain.run (node:domain:389:15) at Runtime.handler (/var/task/node_modules/zapier-platform-core/src/tools/create-lambda-handler.js:192:19) at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1085:29)

 

how do i solve this problem? Could you help ?

Be the first to reply!

Reply