Forum Discussion
All of the above solutions worked, I was wondering if we could take this one step forwards with date segregation as below
(earlier it was as per end of the year, now its one year cycle, and also the diff between the start and end date should not be greater than 365/366 days considering leap years if possible )
Input :
ID StartDate EndDate
1 2016-05-12 2019-11-30
Output :
ID StartDate EndDate
1 2016-05-12 2016-11-30
1 2016-11-31 2017-11-30
1 2017-11-31 2018-11-30
1 2018-11-31 2019-11-30
this is how the contract management system would also be implemented.
Hi Rich:
You should be passing the generated bearer token for the task. Something like
Authorization: Bearer 9V9HGRt0m9BRgD42AZWpzC14QuYABCDE
Is this a triggered or Ultra task ?
- richard_griffit5 years agoNew Contributor
I had also tried that approach passing the
"Authorization" : "Bearer {token_value}"
But still receiving a 401. I did notice that the browser asked for my credentials where as postman didn’t. Hence why i tested with basic.
I am using a triggered task, unfortunately I’m not clued up on the Ultra Tasks - is this something i should be using in this scenario?
Thanks for your response
Regards
RichHi Rich:
A triggered task should be fine for what you’re doing. An Ultra pipeline/task runs constantly and is meant for real-time processing. You can read more about it here.
https://docs-snaplogic.atlassian.net/wiki/spaces/SD/pages/1438189/Triggered+Tasks
If you don’t supply a bearer token, then you need to supply your SnapLogic credentials. It sounds like neither is working you (that is, you’re getting a 401).
I’ve verified a simple triggered task using Curl and also a Java client. I assume the bearer token is valid and you have verified the authorization header is written into the request for your React app.
Here is curl request with a valid bearer token:
$ curl -verbose -X POST \ -H "Authorization: Bearer T3gwZuqhcc1no4ZBltrZi4XVTqiPwfdP" \ -H "Content-Type: application/json" \ -d '{"param1": "value"}' \ http://sm-mbp-mbowen:8888/api/1/rest/slsched/feed/snaplogic/projects/support/simple-task-1 REQUEST: > POST /api/1/rest/slsched/feed/snaplogic/projects/support/simple-task-1 HTTP/1.1 > Host: sm-mbp-mbowen:8888 > User-Agent: curl/7.54.0 > Accept: */* > Referer: rbose > Authorization: Bearer T3gwZuqhcc1no4ZBltrZi4XVTqiPwfdP > Content-Type: application/json > Content-Length: 19 RESPONSE: < HTTP/1.1 200 OK ... [ {"content":{"param1":"value"}} ]
A curl request with my SnapLogic credentials:
$ curl --user mbowen@snaplogic.com:<password> -verbose -X POST \ -H "Content-Type: application/json" \ -d '{"param1": "value"}' \ http://sm-mbp-mbowen:8888/api/1/rest/slsched/feed/snaplogic/projects/support/simple-task-1 REQUEST: > POST /api/1/rest/slsched/feed/snaplogic/projects/support/simple-task-1 HTTP/1.1 > Host: sm-mbp-mbowen:8888 > Authorization: Basic YWRtaW5Ac25hcGxvZ2ljLmNvbTpBZG0xbkAxMno= > User-Agent: curl/7.54.0 > Accept: */* > Referer: rbose > Content-Type: application/json > Content-Length: 19 RESPONSE: < HTTP/1.1 200 OK ... [ {"content":{"param1":"value"}} ]
I will get a 401 if either the token or credentials aren’t valid.
< HTTP/1.1 401 UNAUTHORIZED {"response_map": {"error_list": [{"message": "Authentication required"}]}, "http_status_code": 401}
It sounds like you are able to trigger the task via Postman, so you’re passing the right authentication bits. Is your browser configured to use a proxy? Seems something with the React app.
Related Content
- 4 months ago
- 3 years ago