ADP API Update Worker Information - post

I am trying to make updates within the ADP Worker API, though I keep getting "403: Invalid Scope" for the error. I am using this reference guide, specifically the People > Personal Information > Personal Profile > Contact > Add Home Phone section.
I can interact with the API through GET requests, though I am unable to POST. I am using the URL:
https://api.adp.com/events/hr/v1/worker.personal-communication.landline.add
Body Payload:
{
"events": [
{
"data": {
"eventContext": {
"worker": {
"associateOID": "exampleID123123"
}
},
"transform": {
"worker": {
"person": {
"communication": {
"landline": {
"areaDialing": "240",
"dialNumber": "4567896"
}
}
}
}
}
},
"links": []
}
]
}
Response:
{
"response": {
"responseCode": 403,
"methodCode": "POST",
"resourceUri": {
"href": "/events/hr/v1/worker.personal-communication.landline.add"
},
"serverRequestDateTime": "2021-09-09T18:26:44.607Z",
"applicationCode": {
"code": 403,
"typeCode": "error",
"message": "Invalid Scope"
},
"client_ip_adddress": "xxx.xx.xxx.xxxx",
"adp-correlationID": "xxxxxxxxx-xxxxxxxxxxx-xxxxxxxxxx"
}
}
Any suggestions? Thank you in advance!

After some searching, I believe the answer to my initial question is that we are required to contact our ADP representative to add the ability to hit the Event API. We only had access to the Worker API, which allowed successful calls previously.

Related

How to restart a spring cloud dataflow stream while it is deploying

It seems that the scdf folks decided that this should be forbidden functionality as this returns an error:
curl -X DELETE 'http://localhost:9393/streams/deployments/test' && \
curl -X POST 'http://localhost:9393/streams/deployments/test'
{
"_embedded": {
"errors": [{
"message": "Statemachine is not in state ready to do DELETE",
"logref": "SkipperException",
"_links": {
"self": {
"href": "/"
}
}
}]
}
}
{
"_embedded": {
"errors": [{
"message": "Stream 'test' is already being deployed",
"logref": "StreamAlreadyDeployingException",
"_links": {
"self": {
"href": "/"
}
}
}]
}
}
are there any known ways to do this (or workarounds)?
the use case is that as soon as i ran the above commands, i realized that I coded an error in one of the spring cloud stream apps defined in that stream, and now I needed to change it. the bug caused one of the apps to hang. now i have to recreate my definition.

Request sent from Swagger UI not resulting in Postman x-www-form-urlencoded response

I'm currently configuring a Swagger file to utilize OAuth to retrieve tokens from a site. For brevity, I have removed my schemes and most of my paths as those are fine.
{
"openapi": "3.0.2",
"info": {
"title": "swagger",
"version": "1.0.0",
"description": ""
},
"servers": [
{
"url": "url"
}
],
"paths": {
"/oauth_token.do": {
"post": {
"requestBody": {
"required": true,
"content": {
"application/x-www-form-urlencoded": {
"schema": {
"type": "object"
}
}
}
}
}
}
},
"components": {
"securitySchemes": {
"OAuth": {
"type": "oauth2",
"flows": {
"password": {
"tokenUrl": "/oauth_token.do",
"refreshUrl": "/oauth_token.do",
"scopes": {
"useraccount": "utilize user account"
}
}
}
}
}
}
"security": [
{
"OAuth": ["useraccount"]
}
]
}
The endpoint for this API specifies that I should use x-www-form-urlencoded in the header as the Content-Type. When executing this request in Postman, it returns 200 with the desired response.
However, with https://editor.swagger.io I input the same postman request to get the fetch failed error with my Authorize button. To test for this, I created a custom path that specifies that the content should be x-www-form-urlencoded and this also fails.
So, what am I missing in this case? Any help would be appreciated.
I believe the issue was I did not fill out some portions I added on the response for path. Instead I opted to only leave description for the 200 response.
The main error I'm getting now is CORS related which is unrelated to the original question. I'll mark this answered for now.

Jira API: Add Comment Using Edit Endpoint

Jira has a an /edit endpoint which can be used to add a comment. There is an example in their documentation that suggests this input body to accomplish this:
{
"update": {
"comment": [
{
"add": {
"body": "It is time to finish this task"
}
}
]
}
}
I create the exact same input in my Java code:
private String createEditBody() {
JsonNodeFactory jsonNodeFactory = JsonNodeFactory.instance;
ObjectNode payload = jsonNodeFactory.objectNode();
ObjectNode update = payload.putObject("update");
ArrayNode comments = update.putArray("comment");
ObjectNode add = comments.addObject();
ObjectNode commentBody = add.putObject("add");
commentBody.put("body", "this is a test");
return payload.toString();
}
but when I send this PUT request I get an error saying that the "Operation value must be of type Atlassian Document Format"!
Checking the ADF format it says that "version", "type" and "content" are required for this format. So although their documentation example doesn't seem to be ADF format, I'm trying to guess the format and change it. Here's what I accomplished after modifying my code:
{
"update": {
"comment": [
{
"add": {
"version": 1,
"type": "paragraph",
"content": [
{
"body": "this is a test"
}
]
}
}
]
}
}
the add operation seems to be an ADF but now I get 500 (internal server error). Can you help me find the issue?
Note that the above example from Atlassian documentation is for "Jira Server Platform" but the instance I'm working with is "Jira Cloud Platform" although I think the behaviour should be the same for this endpoint.
after tinkering with the input body, I was able to form the right request body! This will work:
{
"update": {
"comment": [
{
"add": {
"body": {
"version": 1,
"type": "doc",
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "this is a test"
}
]
}
]
}
}
}
]
}
}
The annoying things that I learned along the way:
Jira's documentation is WRONG!! Sending the request in their example will fail!!
after making a few changes, I was able to get 204 from the endpoint while still comment was not being posted! And I guessed that the format is not correct and kept digging! But don't know why Jira returns 204 when it fails!!!

Twilio autopilot redirect not working properly

Im having a problem in getting Autopilot redirect to work
After redirecting to my POST url it stops saying anything.
Below is my code:
{
"actions": [
{
"collect": {
"name": "password_reset_collect",
"questions": [
{
"question": "I will perform password reset to your account. Do you wish to continue?",
"name": "continue",
"type": "Twilio.YES_NO"
}
],
"on_complete": {
"redirect": "https://88fb4b1a.ngrok.io/Voice/Post"
}
}
},
{
"remember": {
"action_query": "password_reset"
}
}
]
}
and in my POST url it returns JSON result using return Content() as follows
var response = "{\"actions\": [{\"say\": {\"speech\": \"Thank you! Have a good day\" }},{\"listen\": true }]}";
return Content(response, "application/json");
result:
{
"actions": [
{
"say": {
"speech": "Thank you! Have a good day"
}
},
{
"listen": true
}
]
}
It never say what I specified in the on JSON and the call end
What am I doing wrong?
Twilio developer evangelist here.
I'd try putting Remember before Collect, as mentioned on the Actions docs page.

Can't Delete Youtube Subscription With API

I have the code setup for the Youtube API with oauth login. Login appears to work properly. I can even see the requests hitting my analytics. However, when I run the code to unsubscribe from a channel, it never works on any channel ID I give it. It should be noted that I'm using the exact example from googles dev docs(see "full sample" option for javascript)... I'm guessing the code is correct and this is some other auth/lookup problem.
API code:
alert("deleting steven!!!!!!");
buildApiRequest('DELETE',
'/youtube/v3/subscriptions',
{'id': 'UCMtFAi84ehTSYSE9XoHefig'});
Stock Youtube API Code:
function executeRequest(request) {
request.execute(function(response) {
console.log(response);
});
}
function buildApiRequest(requestMethod, path, params, properties) {
params = removeEmptyParams(params);
var request;
if (properties) {
var resource = createResource(properties);
request = gapi.client.request({
'body': resource,
'method': requestMethod,
'path': path,
'params': params
});
} else {
request = gapi.client.request({
'method': requestMethod,
'path': path,
'params': params
});
}
executeRequest(request);
}
Here is the error:
{
"error": {
"errors": [
{
"domain": "youtube.subscription",
"reason": "subscriptionNotFound",
"message": "The subscription that you are trying to delete cannot be found. Check the value of the requests \u003ccode\u003eid\u003c/code\u003e parameter to ensure that it is correct."
}
],
"code": 404,
"message": "The subscription that you are trying to delete cannot be found. Check the value of the requests \u003ccode\u003eid\u003c/code\u003e parameter to ensure that it is correct."
}
}
Remember that the ID you have to send is not the channel ID. It's the ID of the subscriptions.
You can get it by sending request to check your subscriptions with the channel. For example
Request:
buildApiRequest('GET',
'/youtube/v3/subscriptions',
{'forChannelId': 'UCEhZglE9MQ4zTL5ErNXt5mg',
'mine': 'true',
'part': 'snippet,contentDetails'});
Response:
{
"kind": "youtube#subscription",
"etag": "\"XI7nbFXulYBIpL0ayR_gDh3eu1k/KrR9MNb4Xs1eNjWMxAH-f5ccsos\"",
"id": "Xmg72z6q83hK2hjx0J4ZwNVcgGz8fu9JCjeHu6eIb3M",
"snippet": {
"publishedAt": "2018-09-30T16:51:47.000Z",
"title": "Rebeca Willett",
"description": "",
"resourceId": {
"kind": "youtube#channel",
"channelId": "UCEhZglE9MQ4zTL5ErNXt5mg"
},
"channelId": "UCWfZYaoFrUOSoHNhCOOqKCQ",
"thumbnails": {
...
}
Using ID in the response to send request for unsubscribing:
buildApiRequest('DELETE',
'/youtube/v3/subscriptions',
{'id': 'Xmg72z6q83hK2hjx0J4ZwNVcgGz8fu9JCjeHu6eIb3M'});
Here is the google docs for getting subscriptions ID

Resources