Content-type header not being sent from web activity in ADF v2 - azure-data-factory

We use a web activity in ADF v2 to interact with the Azure Automation Account API (Job creation) based on this specification https://learn.microsoft.com/en-us/rest/api/automation/job/create
Since 09-04-2020 the PUT web call isn't working because the header "Content-Type : application/json" is not being sent. The pipeline that contain the activity hasn't changed in months, just stopped working suddenly with the error:
Operation on target Automation - AAS Processing failed:
{
"code": "UnsupportedMediaType",
"message": "{\"Message\":\"The request entity's media type 'text/plain' is not supported for this resource.\"}"
}
But the input request for the pipeline, does include the header:
{
"url": "https://management.azure.com/subscriptions/xxxxx/resourceGroups/xxxxx/providers/Microsoft.Automation/automationAccounts/xxxxx/jobs/55a1bfa2-340c-4120-ba42-43df9e9f4e14?api-version=2017-05-15-preview",
"method": "PUT",
"headers": {
"Content-type": "application/json"
},
"body": "{\"properties\":{\"runbook\":{\"name\":\"aas-masterdata-management\"},\"parameters\":{\"Masterdata_Table\":\"RLS\"},\"runOn\":\"\"}}",
"authentication": {
"type": "MSI",
"resource": "https://management.azure.com"
}
}
I've tried so far:
Recreate the pipeline
Test in a different ADF instance
Delete and redeploy all the pipelines
Delete the header
Change the header to lowercase, uppercase, etc
Add the header twice
Use a self-hosted integration runtime
Test in Debug mode
Any of these tests have been successful. Just for confirmation, I've run the same call from Postman and from the rest api debug tool included within the Api documentation, both worked perfectly, if I set the content header to text/plain in postman or in the web tool I get exactly the same error than in ADF v2. It seems that something has changed in the web call activity of ADF v2 that hardcodes the content header as "text/plain" somehow.
Is someone facing this same issue ? As I said, pipeline definition hasn't changed in months, just stopped working few days ago.

Answer from the ADF platform team:
I got update from Product team that using "Content-Type" instead of "Content-type" will resolve this issue. This can be referred in the documentation
It seems that they accepted "Content-type" before, as it was working several months with that config, but not anymore. So if someone experiences the same problem, here is the answer.
Thanks.

If you are creating the ADF webhook activity using a bicep file, I found this approach works to set the Content-Type in the header parameter.
Define a string variable with the hyphenated Content-Type name
Use string interpolation to include the variable in the headers param
var contentType = 'Content-Type'
activities: [
{
dependsOn: []
description: ''
name: 'MyWebHook'
userProperties: []
type: 'WebHook'
typeProperties: {
body: {
value: '#json(concat(\'{"data":"\',item().data,\'","startTime":"\',item().startTime,\'","endTime\\":"\',item().endTime,\'"}\'))'
type: 'Expression'
}
headers: {
'${contentType}': 'application/json'
}
method: 'POST'
reportStatusOnCallBack: true
timeout: '00:10:00'
url: listCallbackURL('${logic_app_id}/triggers/manual', '2016-10-01').value
}
}
]

Related

Send file using Axios Assyst REST API

Working in Blue Prism .Net environment utilising the HTTP utility to make calls to Axios Assyst (an IT service desk 3rd party software).
My HTTP request is as per below:
POST /assystREST/v2/site/10/attachments/binary HTTP/1.1
Host: <myserver>:<myport>
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary<base64 encode here>
Accept: application/json
Authorization: Basic <base64 encoded key>
{
"eventId": 10010045,
"fileName": "C:\Users\Me\Desktop\MyFile.msg",
"attachment": "data:;base64,<base64 encoded file>
"onBehalfOfUser": "MR ROBOT",
"custom": {},
"attachedByUserId": <my ID>,
"name": "C:\Users\Me\Desktop\MyFile.msg",
"event":{
"assystRESTType": "event",
"assystRESTXMLType": "eventDto",
"id": 10010045
},
"attachedByUser":{
"assystRESTType": "assystUser",
"assystRESTXMLType": "assystUserDto",
"name": "Mr Robot - Test",
"id": <my ID>,
"shortCode": "MR ROBOT"
}
}
I can create and close my tickets but unable to send/save files to my newly created tickets. I get a HTTP STATUS CODE 410-GONE and the below exception JSON response:
{
"type": "NotFoundException",
"message": "The requested resource is not available.",
"messageKey": "rest.exceptions.NotFoundException",
"diagnostic": "Could not find resource for relative : /site/10/attachments/binary of full path: http://server:port/assystREST/v2/site/10/attachments/binary"
}
I'm following the instructions and guidelines noted in the official Axios Assyst Web Service wiki(per the below link), i.e. I'm using multipart/form-data while sending the file, a .msg file, and the binary of said file (yes I know this adds 33% more to the file size): https://wiki.axiossystems.com/assyst10SP75Wiki/index.php/Integrations:assystREST#Attachments
My issue is that 400 status codes would denote an issue on the client side but I've checked internally re firewall/port being used and nothing is being blocked.
I've reasearched 410 status codes and it would seem that the issue is server side but one that the server is not willing to elaborate on.
For testing I'm using Postman as it allows for greater flexibility rather than using Blue Prism, the JSON response is the same.
Looking for some guidance re status code 410 and possible solutions, note I've limited scope re options due to Blue Prisms .net vbo's.

How to update Test Execution status (Pas/Fail) in jira using zapi (rest Api) with protractor framework

How to update Test execution status ( Pass/Fail) in Jira in automatically using protractor framework.
Test management tool used Jira with zephyr plugin.
Any Rest API plugin available? Please provide example.
Any help would be appreciated.
In order to update the execution status you need to perform a REST call with this details:
Method: PUT
URL: https://{your_company_jira_url}/jira/rest/zapi/latest/execution/{executionId}/execute
Headers:
Content-Type: application/json
And in body specify this JSON:
For PASS:
{ "status": 1 }
For FAIL:
{ "status": 2 }
You can find more information (depending of your Zephyr/Jira version) in: https://zfjcloud.docs.apiary.io/#
I hope helps.

How to impersonate the user in Jira add-on to use Jira REST API on behalf of user

I'm looking for help of somebody who knows something about Jira add-ons.
I'm trying to implement Jira add-on with an ability to create issues on behalf of a user.
So, I completed all steps (as I think) leading me to my goal, but I faced a problem with impersonating. When I try to create an issue using Jira REST API, I receive the following error:
{
"error": "Add-on 'com.example.myapp' disallowed to impersonate the user because 'no valid active user exists'"
}
What was done:
Folowing the getting started tutorial I created the add-on descriptor:
{
"name": "Hello World",
"description": "Atlassian Connect app",
"key": "com.example.myapp",
"baseUrl": "https://url.ngrok.io",
"vendor": {
"name": "Example, Inc.",
"url": "http://example.com"
},
"authentication": {
"type": "jwt"
},
"scopes": [
"act_as_user",
"read",
"write",
],
"lifecycle": {
"installed": "/api/created",
},
"apiVersion": 1
}
I also implemented webhook to handle 'installed' callback from add-on like described here. So, when a user installs the add-on the webhook will receive the following object:
{
'key': 'com.example.myapp',
'clientKey': '<client key>',
'oauthClientId': '<OAuth client ID>',
'publicKey': '<public key>',
'sharedSecret': '<shared secret>',
'serverVersion': '100095',
'pluginsVersion': '1.250.0',
'baseUrl': 'https://<user's domain>.atlassian.net',
'productType': 'jira',
'description': 'Description',
'eventType': 'installed'
}
Using this data I generated JWT signed with the shared secret like described in the tutorial. So, my JWT payload includes the following claims:
{
'iss': 'urn:atlassian:connect:clientid:<OAuth client ID>',
'sub': 'urn:atlassian:connect:useraccountid:<client key>',
'tnt': 'https://<user's domain>.atlassian.net',
'iss': '<created at>',
'exp': '<created at + 1 minute>'
}
The next step I performed is access token generation using auth.atlassian.io/oauth2/token endpoint and the following parameters:
grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer&assertion=<my JWT>&scope=ACT_AS_USER READ WRITE
The result of all these actions is an access token witch I can use to perform REST API requests. But the error described above returned every time I try to create Jira issue performing POST [user's domain].atlassian.net/rest/api/2/issue/ with Authorization: Bearer [access_token] header.
What I've noticed is that account ID in installed callback object (clientKey) has 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' (uuid) format. But when I open my account in Jira (account in witch the add-on is installed) I see that the account ID in URL has 'YYYYYY:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' format. I prepended the subject in my JWT payload with YYYYYY part:
'sub': 'urn:atlassian:connect:useraccountid:'YYYYYY:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
and generated a new access token using this JWT. I've used new access token to create an issue and it was successfully created, the reporter of the issue is a user installed my add-on, just like I wished.
Finally, the question is: where can I find that YYYYYY part for my add-on? How to get it automatically? What I've missed following the tutorials? Any help will be appreciated.
Thank you!

How Do I Change The Project Owner Using REST API

I want to change the project owner of a project using REST API. I know there is a "/Owner" endpoint and I can get the owner without any problems with the following GET:
site/_api/ProjectServer/Projects('2cc734f2-cd16-4f09-8632-a2bc74a32577')/Owner
So how do I change the project owner using REST API?
This is an old issue but I figured it might help someone since I recently struggeled with this too.
I have only tested this on Project Online and not on-prem, probably works the same on Project Server 2016
Start by checking out the project
Send a PATCH request to:
_api/ProjectServer/Projects('PROJECT ID')/Draft
with the following headers:
Accept: application/json; odata=verbose
Content-Type: application/json; odata=verbose
X-RequestDigest: The request digest
If-Match: Either "*" or the etag value you get from checking out the project
and the request body:
{
"__metadata": {
"type": "PS.DraftProject"
},
"OwnerId": "SharePoint User ID of the owner"
}
It's important that you send the "OwnerId" value as a string, not a number.
Publish the project
The general way to change site owners using REST API according to MSDN is:
POST http://<sitecollection>/<site>/_api/site/owner
So in your case you should just have to change from a GET command to POST

How to update HP Fortify 'Processing Rules' via REST

I've read the documentation, and I get the REST API GET URL...
http://localhost:8080/ssc/api/v1/projectVersions/6/resultProcessingRules
To work and return a list of the 'Profile - Processing Rules' for my application (via ID 6).
e.g.
"data": [
{
"displayName": "Require approval if the Build Project is different between scans",
"identifier": "com.fortify.manager.BLL.processingrules.BuildProjectProcessingRule",
"enabled": true,
"displayable": true
}
What I can't get to work is the PUT command to set this from 'enabled=true' to 'enabled=false'
I get back the same error message each time...
{
"message": "An unexpected error occurred accessing resource of type Project Version Result Processing Rules.",
"responseCode": 500,
"errorCode": -20010
}
And the log just says...
2016-11-27 23:24:40,076 [ERROR] com.fortify.server.platform.endpoints.rest.ProjectVersionResultProcessingRulesController - ApiGeneralResourceException: &apos;An unexpected error occurred accessing resource of type Project Version Result Processing Rules.&apos; [url: /ssc/api/v1/projectVersions/6/resultProcessingRules]
2016-11-27 23:24:40,077 [WARN] org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver - Handler execution resulted in exception: java.lang.String cannot be cast to java.util.List
Can anyone tell me what the correct payload should be for this command?
Using Postman, I got this to work:
Here are the headers I used
Authorization = FortifyToken A13D...E2
Content-Type = application/json
Accept = application/json
And here is the body:
[
{
"displayName": "Require approval if the Build Project is different between scans",
"identifier": "com.fortify.manager.BLL.processingrules.BuildProjectProcessingRule",
"enabled": true,
"displayable": true
}
]
NOTE
The trick I have used when trying to figure out who to call the REST API is to perform the action through the HTML5 UI while looking at the traffic (Fiddler, the browser's dev tools, etc). Then looking at the requests that it sends. The HTML5 interface uses the REST API under the hood.