It looks like I was missing the "renderRequest" tag around the payload. This is not required when you call the JSReports Console App API
{
"renderRequest":{
"template":{"name": "XXJobSchedule", "shortid": "xxx56p", "recipe": "html"},
"options":{"reports":{"save":true} },
"data": {
.....
}
}
}
Posts made by Jerry Rodriguez
-
RE: AWS lambda API error required tempate _id, shortid, name
-
AWS lambda API error required tempate _id, shortid, name
I'm seeing the following error when calling an API tied to the jsreports aws function. This works when I call the API directly to the JRS Report console. Any ideas on what I may be doing wrong?
Fri Aug 11 17:27:59 UTC 2023 : HTTP Method: POST, Resource Path: /v1/report
Fri Aug 11 17:27:59 UTC 2023 : Method request path: {}
Fri Aug 11 17:27:59 UTC 2023 : Method request query string: {}
Fri Aug 11 17:27:59 UTC 2023 : Method request headers: {}
Fri Aug 11 17:27:59 UTC 2023 : Method request body before transformations: {
"template":{"name": "SpgmJobSchedule", "shortid":"t2mHjC56p"},
"folder": {"shortid": "MHhhPe5"},
"options":{"reports":{"save":true} },
"data":{
"header": {
"params": {
"applicationGuid": "0B43E124-7755-4194-A441-1836F8E6DB48",
"jobId": "10024596"
},
"otherInfo": {
"correlationId": "6e157773-be6f-477d-9170-bc169d0de6ea"
}
},
"result": [
{
"jobName": "Job 3",
"subdivisionName": "subDiv 1",
"taskId": 37,
"taskName": "task 37",
"taskStatus": "A",
"adjStartDate": "2021-10-07T00:00:00.000Z",
"initStartDate": "2021-10-07T00:00:00.000Z",
"daysBehind": 0,
"supplierName": "Self Supplied",
"phaseGroup": 0
}[TRUNCATED]
Fri Aug 11 17:27:59 UTC 2023 : Endpoint request URI: https://lambda.us-west-2.amazonaws.com/2015-03-31/functions/arn:aws:lambda:region:acct:function:SPGMJSReport-function/invocations
Fri Aug 11 17:27:59 UTC 2023 : Endpoint request headers: {X-Amz-Date=20230811T172759Z, x-amzn-apigateway-api-id=xxxx, Accept=application/json, User-Agent=AmazonAPIGateway_xxxx, Host=lambda.us-west-2.amazonaws.com, X-Amz-Content-Sha256=1ac0742, X-Amzn-Trace-Id=Root=1-64d66f9f-, x-amzn-lambda-integration-tag=6903, Authorization=********, X-Amz-Source-Arn=arn:aws:execute-api:us-west-2:xxxxxx:xxxxi/test-invoke-stage/POST/v1/report, X-Amz-Security-Token=IQoJbvAw2+TF [TRUNCATED]
Fri Aug 11 17:27:59 UTC 2023 : Endpoint request body after transformations: {"resource":"/v1/report","path":"/v1/report","httpMethod":"POST","headers":null,"multiValueHeaders":null,"queryStringParameters":null,"multiValueQueryStringParameters":null,"pathParameters":null,"stageVariables":null,"requestContext":{"resourceId":"kno7a3","resourcePath":"/v1/report","httpMethod":"POST","extendedRequestId":"JgZg7EzRvHcF9Rg=","requestTime":"11/Aug/2023:17:27:59 +0000","path":"/v1/report","accountId":"xxx1","protocol":"HTTP/1.1","stage":"test-invoke-stage","domainPrefix":"testPrefix","requestTimeEpoch":1691774879233,"requestId":"6903d7ad-f93b-40bc-9768-ea14a9d029ef","identity":{"cognitoIdentityPoolId":null,"cognitoIdentityId":null,"apiKey":"test-invoke-api-key","principalOrgId":null,"cognitoAuthenticationType":null,"userArn":"arn:aws:sts::xxxxx:assumed-role/AWSReservedSSO_AWSAdministratorAccess_xxxx/jrod@xx.com","apiKeyId":"test-invoke-api-key-id","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) Apple [TRUNCATED]
Fri Aug 11 17:27:59 UTC 2023 : Sending request to https://lambda.us-west-2.amazonaws.com/2015-03-31/functions/arn:aws:lambda:region:xxxxx:function:SPGMJSReport-function/invocations
Fri Aug 11 17:27:59 UTC 2023 : Received response. Status: 200, Integration latency: 163 ms
Fri Aug 11 17:27:59 UTC 2023 : Endpoint response headers: {Date=Fri, 11 Aug 2023 17:27:59 GMT, Content-Type=application/json, Content-Length=1091, Connection=keep-alive, x-amzn-RequestId=2de01b49-3ecb-401c-aede-f34ca5fddbed, X-Amz-Function-Error=Unhandled, x-amzn-Remapped-Content-Length=0, X-Amz-Executed-Version=$LATEST, X-Amzn-Trace-Id=root=1-64d66f9f-7faf64125e31ef2c052242f3;sampled=0;lineage=2b960001:0}
Fri Aug 11 17:27:59 UTC 2023 : Endpoint response body before transformations: {"errorType":"Error","errorMessage":"Template must contains _id, name, shortid or content attribute","trace":["Error: Template must contains _id, name, shortid or content attribute"," at module.exports (/opt/nodejs/node_modules/@jsreport/jsreport-core/lib/shared/createError.js:10:13)"," at WorkerReporter.createError (/opt/nodejs/node_modules/@jsreport/jsreport-core/lib/shared/reporter.js:47:12)"," at AsyncFunction.<anonymous> (/opt/nodejs/node_modules/@jsreport/jsreport-core/lib/worker/templates.js:14:24)"," at ListenerCollection.fire (/opt/nodejs/node_modules/@jsreport/jsreport-core/lib/shared/listenerCollection.js:157:32)"," at async beforeRender (/opt/nodejs/node_modules/@jsreport/jsreport-core/lib/worker/render/render.js:25:5)"," at async WorkerReporter._render (/opt/nodejs/node_modules/@jsreport/jsreport-core/lib/worker/render/render.js:146:7)"," at async /opt/nodejs/node_modules/@jsreport/jsreport-core/lib/worker/reporter.js:179:19"," [TRUNCATED]
Fri Aug 11 17:27:59 UTC 2023 : Lambda execution failed with status 200 due to customer function error: Template must contains _id, name, shortid or content attribute. Lambda request id: 2de01b49-3ecb-401c-aede-f34ca5fddbed
Fri Aug 11 17:27:59 UTC 2023 : Method completed with status: 502 -
RE: jsreport aws lambda starter kit invalid version for license
Thank You!!! I will give that a try
-
jsreport aws lambda starter kit invalid version for license
I recently downloaded the jsreport-aws-lambda-starter-kit, when I plugged in my licenses I get the error listed below. Is there a way to downgrade the starter kit to my license version?
error: Error occurred during reporter init: Error: The license key is not valid for version 3.12.0 because the 6 months of free updates ended on 6/13/2022 and version 3.12.0 was released on 6/8/2023. The latest eligible version for this license key is 3.6.2. To upgrade your license and use the latest jsreport, please visit your customer's dashboard or contact support.
-
Convert report to XLS using jsreport.render and authentication
Currently in our HTML report we have a button to generate the report in XLS, the button uses the function listed below. The issue is that we use Authentication so we need to set the token in the header in order for it to work. Is there a way to not hardcode the token in the function?
function toXLS() {
jsreport.headers['Authorization'] = "Basic xxxx==";
jsreport.render({
template: {
content: document.getElementById('printedArea').innerHTML,
engine: "handlebars",
recipe: "html-to-xlsx",
},
data: '{{req.data}}'
}).then(r => r.download('report.xls')).catch(console.error);
}
</script> -
RE: ReferenceError: Can't find variable: jsreport
Thank you Syracine69, I saw this sample working on the deep dive demo from Jan Blaha. (https://www.youtube.com/watch?v=fhOQ0HPjK6s) I was thinking I might just be missing a script source tag with the code that defines the jsreport variable. I do see that it embeds jsreport.umd.js but It may be missing something else.
-
ReferenceError: Can't find variable: jsreport
I'm using the JSReports API to retrieve the HTM for a report using html-with-browser-client handlebars. I added a button to the report to create and excel file to be created when a user clicks on it. with the following function:
<script>
function toXLS() {
jsreport.render({
template: {
name: 'SpgmJobSchedule',
engine: "handlebars",
recipe: "html-to-xlsx",
}
}).then(r => r.download('report.xls')).catch(console.error);
}
</script>When I run the report from the studio it works fine but when I call the API to get the HTML and render the report on my application window the button does not work and it throws error: ReferenceError: Can't find variable: jsreport . Any help with this would be greatly appeciated.