Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagets
var client, request, response;
client = $Rest.Create(restUrl + '/employers/60ec35c7-7595-4c3a-bb12-f6c8a3be953a/payrun/Year2019/Monthly');

request = client.Request();
request.Method = 'Put';
request.AddHeader('Content-Type', contentType);
request.AddHeader('Authorization', 'Basic ' + authorizationCode);
request.Expect('Created');
request.Expect('BadRequest');

try {
    console.info('Calling ' + client.Url);
     
    response = request.Put().ToJson();
 
    if(response.status == 'BadRequest') {
        console.error(response.error);
        throw response;
    }
 
    console.info(response.status);
}
catch (err) {
    throw err.error;
}

Examples

Code Block
languagets
var client, request;
client = $Rest.Create(restUrl + '/employers/60ec35c7-7595-4c3a-bb12-f6c8a3be953a/payrun/Year2019/Monthly');

request = client.Request();
request.Method = 'Put';
request.AddHeader('Content-Type', contentType);
request.AddHeader('Authorization', 'Basic ' + authorizationCode);

console.info(request.Expect('Created').Put().ToJson());

...

Code Block
languagets
var client, request, response;
client = $Rest.Create(restUrl + '/employers/60ec35c7-7595-4c3a-bb12-f6c8a3be953a/payrun/Year2019/Monthly');

request = client.Request();
request.Method = 'Put';
request.AddHeader('Content-Type', contentType);
request.AddHeader('Authorization', 'Basic ' + authorizationCode);
request.Expect('Created');
request.Expect('BadRequest');

try {
    console.info('Calling ' + client.Url);
     
    response = request.Put().ToJson();
 
    if(response.status == 'BadRequest') {
        console.error(response.error);
        throw response;
    }
 
    console.info(response.status);
}
catch (err) {
    throw err.error;
}