Generic Resource
PEPPERI NOTIFICATION SERVICE
Actions Queue
CPI Node
TODO training

Upsert Code Job

  1. Update is done using the UUID only

  2. when Posting IsScheduled parameter = true it does the actual scheduling.

  3. Cron Expression changes are affecting the NextRunTime as well as the IsScheduled - but only IsScheduled will insert it into scheduling.

When OwnerID of a Code Job object is presented at object creation - an update to this object must include custom authorization header:

X-Pepperi-OwnerID : <the OwnerID>

post
Upsert Code Job

https://api.pepperi.com/v1.0/code_jobs
Upsert By UUID
Request
Response
Request
Path Parameters
optional
object
Same object as the GET
Response
200: OK

Make sure to escape your code correctly when inserting code to "DarftCode" - example:

Note: use 5 fields cron expression - without seconds and year fields

{
"CodeJobName" : "test code job",
"DraftCode": "function wait(ms){\naddLogEntry(ms); var start = new Date().getTime();\nvar end = start;\n while(end < start + ms) {end = new Date().getTime();\n }} \n var XMLHttpRequest = require(\"xmlhttprequest\").XMLHttpRequest; \nfunction authenticateUser(){ var token =getOAuthAccessToken() ; return \"Bearer \" + token;} \n function CallWebAPI() { var request = new XMLHttpRequest(); request.open(\"GET\", \"https://apint.stage.pepperi.com/restapi/PepperiAPInt.Data.svc/V1.0/transactions?page_size=10&\", true); request.setRequestHeader(\"Authorization\", authenticateUser()); request.send(null); request.onreadystatechange = function(){addLogEntry('ERROR',request.responseText);}; return request.responseText; } CallWebAPI();"
}

Error Codes :

Scenario

Error Code

Fault String

HTTP Status Code

OwnerID is different from DB ownerID

InvalidParameterCJ006

Invalid addon owner uuid

400

Update - Cannot find Code Job

InvalidParameterCJ004

{ jobUUID } does not exist.

404

Insert - No CodeJobName

InvalidParameterCJ005

Invalid field value. Field: CodeJobName: Value cannot be null or empty.

400

Delta Between Two Events.TotalMinutes < codeJobDelayRetryInMinutes * numberOfTries

InvalidParameterCJ007

Number of tries is not valid. Job next run time cannot be less than the next try.

400

Try to update job type property

InvalidParameterCJ013

Can not update job type

400

Insert - AddonJob type without AddonUUID or AddonPath

InvalidParameterCJ015

Invalid field value. Field: {FieldName}: Value cannot be null or empty.

400

Insert - UserCodeJob type with AddonUUID

InvalidParameterCJ016

AddonUUID is only for AddonJob type

400

Cron Expressions Format:

Field Name

Mandatory

Allowed Values

Allowed Special Characters

Seconds

YES

0-59

, - * /

Minutes

YES

0-59

, - * /

Hours

YES

0-23

, - * /

Day of month

YES

1-31

, - * ? / L W

Month

YES

1-12 or JAN-DEC

, - * /

Day of week

YES

1-7 or SUN-SAT

, - * ? / L #

Year

NO

empty, 1970-2099

, - * /

A cron expression is a string comprised of 6 or 7 fields separated by white space. Fields can contain any of the allowed values, along with various combinations of the allowed special characters for that field. The fields are as follows:

Examples of Cron Expressions:

**Expression**

**Meaning**

0 12 * * *

Fire at 12pm (noon) every day

15 10 * * *

Fire at 10:15am every day

0 9 16 12 *

Fire at 9:00am on 16/12 every year