Unable to export VSTS template using Rest API - azure-devops

I am using the following API however I am unable to extract the template.
https://my.visualstudio.com/_apis/work/processadmin/processes/export/a3939163-8d2c-4027-b4cd-8c5b5385ef16?api-version=4.1-preview
I am getting the following error, I have checked the Process Id and it is correct
{
"count": 1,
"value": {
"Message": "An error has occurred."
}
}
The header info is as follows:
ActivityId →58919c6e-80c8-4e23-8615-b1420c8b33d1
Cache-Control →no-cache
Content-Length →56
Content-Type →application/json; charset=utf-8
Date →Thu, 15 Mar 2018 23:18:37 GMT
Expires →-1
P3P →CP="CAO DSP COR ADMa DEV CONo TELo CUR PSA PSD TAI IVDo OUR SAMi BUS DEM NAV STA UNI COM INT PHY ONL FIN PUR LOC CNT"
Pragma →no-cache
Strict-Transport-Security →max-age=31536000; includeSubDomains
X-AspNet-Version →4.0.30319
X-Content-Type-Options →nosniff
X-FRAME-OPTIONS →SAMEORIGIN
X-MSEdge-Ref →Ref A: 55BDC5BAB8FB4AA9B6F57D7E425CB98F Ref B: SYD03EDGE0409 Ref C: 2018-03-15T23:18:38Z
X-Powered-By →ASP.NET
X-TFS-ProcessId →f4e9e458-9463-41a1-aee4-55eaaf18e13e
X-TFS-Session →58919c6e-80c8-4e23-8615-b1420c8b33d1
X-VSS-E2EID →58919c6e-80c8-4e23-8615-b1420c8b33d1
X-VSS-UserData →609b16af-5515-6e7c-996d-ed1e05e49cf1:bajwa79#hotmail.com

I could reproduce your issue, and have submitted a feedback at website below, let's wait for the response:
https://developercommunity.visualstudio.com/content/problem/216545/unable-to-export-vsts-template-using-rest-api.html
Update:
This feedback has been answered:
In phase 2 or Inherited process model, process XML concept doesn't
exist. It is only for OnPrem XML model (in TFS) and for Hosted XML
process models. The process for which you are making this Rest API
call is an inherited process that's why it's failing. And you don't
need process XML to perform any operation you have different and easy
ways to do so in VSTS. Hope it answers your question. Let me know if
you have any other question.

Related

SharePoint Online REST by using access_token still getting 403

following this article http://www.ktskumar.com/2017/01/access-sharepoint-online-using-postman/
I was able to register an app and get a client_id as well as a security token.
Now if I follow the article, I'm able to get an access token by using Postman, SOAP UI as well as by using a REST client in browser. I'm also able to fetch data from SharePoint using this token.
However, I need to do this from a unix based middleware, which is able to do HTTP calls as well. I tried everything but I can't get it work.
Preparation that has been done before:
register new app by using https://.sharepoint.com/sites//_layouts/15/appregnew.aspx
add app and permission to site collection to grant access by using https://.sharepoint.com/sites//_layouts/15/appinv.aspx
After this, I do some webservice calls like this
I try to get an access token by calling https://accounts.accesscontrol.windows.net/<mytenant_id>/tokens/OAuth/2 and got one. I can use this token in every REST client as well as in Postman. So I assume it is a valid one.
Now I try to retrieve the Title of web by calling this URL https://<my_tenant>.sharepoint.com/sites/<site_collection>/_api/web?$select=Title
This always returns a 403 but only when using middleware system. If I do the same from any other client, it works.
Could someone please enlight me what is going wrong here?
This is how the request header looks like (I've shorten some things)
cookie'='fpc=...some other stuff; domain=.accounts.accesscontrol.windows.net; path=/; secure; HttpOnly; SameSite=None
x-ms-gateway-slice=prod; path=/; SameSite=None; secure; HttpOnly
stsservicecookie=ests; path=/; SameSite=None; secure; HttpOnly'
'User-Agent'='Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0'
'accept'='application/json;odata=verbose'
'Authorization'='Bearer eyJ0eXAiOiJKV1QiLCJhbG... lot following here, but only value of access_token'
This is what the response looks like:
'RESPONSE_HTTP_HEADER_X-ASPNET-VERSION'='4.0.30319'
'RESPONSE_HTTP_HEADER_LAST-MODIFIED'='Tue, 23 Jun 2020 08:10:42 GMT'
'RESPONSE_HTTP_HEADER_X-SHAREPOINTHEALTHSCORE'='1'
'RESPONSE_HTTP_HEADER_X-FORMS_BASED_AUTH_RETURN_URL'='https://<mytenant>.sharepoint.com/_layouts/15/error.aspx'
'RESPONSE_HTTP_HEADER_CACHE-CONTROL'='private, max-age=0'
'RESPONSE_HTTP_DATA'='<?xml version="1.0" encoding="utf-8"?><m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><m:code>-2147024891, System.UnauthorizedAccessException</m:code><m:message xml:lang="en-US">Access denied. You do not have permission to perform this action or access this resource.</m:message></m:error>'
'RESPONSE_HTTP_HEADER_X-POWERED-BY'='ASP.NET'
'RESPONSE_HTTP_HEADER_DATE'='Tue, 23 Jun 2020 08:10:42 GMT'
'RESPONSE_HTTP_STATUSLINE'='Forbidden'
'RESPONSE_HTTP_HEADER_EXPIRES'='Mon, 08 Jun 2020 08:10:42 GMT'
'RESPONSE_HTTP_HEADER_CONTENT-SECURITY-POLICY'='frame-ancestors 'self' teams.microsoft.com *.teams.microsoft.com *.skype.com *.teams.microsoft.us local.teams.office.com;'
'RESPONSE_HTTP_HEADER_MICROSOFTSHAREPOINTTEAMSERVICES'='16.0.0.20203'
'RESPONSE_HTTP_HEADER_X-MSDAVEXT_ERROR'='917656; Access+denied.+Before+opening+files+in+this+location%2c+you+must+first+browse+to+the+web+site+and+select+the+option+to+login+automatically.'
'RESPONSE_HTTP_HEADER_SPREQUESTGUID'='78265f9f-40b3-b000-f2bb-2df685280534'
'RESPONSE_HTTP_HEADER_STRICT-TRANSPORT-SECURITY'='max-age=31536000'
'RESPONSE_HTTP_HEADER_TRANSFER-ENCODING'='chunked'
'RESPONSE_HTTP_HEADER_MS-CV'='n18meLNAALDyuy32hSgFNA.0'
'RESPONSE_HTTP_HEADER_CONTENT-TYPE'='application/xml;charset=utf-8'
'RESPONSE_HTTP_HEADER_P3P'='CP="ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI"'
'RESPONSE_HTTP_HEADER_X-FRAME-OPTIONS'='SAMEORIGIN'
'RESPONSE_HTTP_HEADER_X-IDCRL_AUTH_PARAMS_V1'='IDCRL Type="BPOSIDCRL", EndPoint="/sites/<sitecollection>/_vti_bin/idcrl.svc/", RootDomain="sharepoint.com", Policy="MBI"'
'RESPONSE_HTTP_HEADER_SERVER'='Microsoft-IIS/10.0'
'RESPONSE_HTTP_HEADER_REQUEST-ID'='78265f9f-40b3-b000-f2bb-2df685280534'
'RESPONSE_HTTP_HEADER_X-MS-INVOKEAPP'='1; RequireReadOnly'
'RESPONSE_HTTP_HEADER_X-CONTENT-TYPE-OPTIONS'='nosniff'
'RESPONSE_HTTP_HEADER_X-FORMS_BASED_AUTH_REQUIRED'='https://<mytenant>.sharepoint.com/_forms/default.aspx?ReturnUrl=/_layouts/15/error.aspx&Source=%2f_vti_bin%2fclient.svc%2fweb%3f%24select%3dTitle'
'RESPONSE_HTTP_STATUS'='403'
'RESPONSE_HTTP_HEADER_DATASERVICEVERSION'='3.0'
I also tried it with different HTTP Headers, by using cookies and by skip them. Nothing works from middleware but everything from my PC.
Patrick
You could try this way to get authentication:
https://www.c-sharpcorner.com/article/access-sharepoint-online-rest-api-via-postman-with-user-context/
I use some kind of middleware called "Lobster data". This is a software product to map data between different kind of systems. It's comparable to Microsoft BizTalk or others.
However this software uses some special prefix for HTTP header which I was not aware of. Thanks to their support team, I was able to overcome this issue.
Commonly, if you set a HTTP header, you simple use the name of the header you want to add like "content-type" or "authorization" and pass a value.
When using Lobster, you need to add "REQUEST_HTTP_HEADER_" as a prefix, so it needs to be "REQUEST_HTTP_HEADER_authorization" instead of just "authorization". Otherwise it will not send the data as a HTTP Header.
This is only true when using Lobster and not in general. I wasn't aware that they use this syntax.

OneNote REST API way too slow from a few day ago

I'm developing OneNote add-in which is using OneNote REST API.
It was slightly slow like taking 4-5 secs for an API call but it's way too slow like taking about 1 min for an call from yesterday.
Is it available to check something wrong with session id in response headers?
Request:
https://www.onenote.com/api/v1.0/me/notes/pages
Response:
Cache-Control →no-cache
Content-Encoding →gzip
Content-Length →3614
Content-Type →application/json; odata.metadata=minimal
Date →Fri, 05 May 2017 04:53:29 GMT
Expires →-1
OData-Version →4.0
P3P →CP="CAO DSP COR ADMa DEV CONi TELi CUR PSA PSD TAI IVDi OUR SAMi BUS DEM NAV STA UNI COM INT PHY ONL FIN PUR"
Pragma →no-cache
Preference-Applied →odata.include-annotations=*
Request-Processing-Time →63464.9347 ms
X-AspNet-Version →4.0.30319
X-AuthenticatedUserId →ORGID-5461B3DB-4535-4C86-86B2-4171965B3B3D
X-Content-Type-Options →nosniff
X-CorrelationId →11d0dea1-bcf3-4658-a99b-f3af77d4e208
X-OfficeCluster →ause-000.apimonolith.onenote.com
X-OfficeFE →ApisFrontEnd_IN_2
X-OfficeVersion →16.0.8203.1550
X-Powered-By →ASP.NET
X-RoutingCorrelationId →11d0dea1-bcf3-4658-a99b-f3af77d4e208
X-RoutingOfficeCluster →aue-000.reverseproxy.onenote.com
X-RoutingOfficeFE →ReverseProxyFrontEnd_IN_0
X-RoutingOfficeVersion →16.0.8204.1550
X-RoutingSessionId →67852300-b26a-4b5e-b830-8233acf7cadc
X-UserSessionId →67852300-b26a-4b5e-b830-8233acf7cadc
Thanks for reporting this issue!
If you're fetching OneNote pages, we generally recommend you do it by section or notebook instead of going through the top level collection. (E.g. GET sections/id/pages, notebooks/id/pages.
That said, we do have an issue in Production currently and are working to fix it. I will update this answer once resolved.

watson natural language classifier - Getting 415 FAIL when trying to create a classifier with training_data

Just a couple of month ago, I created a couple of natural language classifiers with the training_data param to send training data as a json string. When I try it now, it fails with return code 415, even with exactly the same call and training data. What changed, and what needs to be done to correct this?
I am using runscope to train the classifier. The following is a call that worked a couple months ago and not now:
POST
https://gateway.watsonplatform.net/natural-language-classifier/api/v1/classifiers
Accept: */*
Accept-Encoding: gzip, deflate
Authorization: Basic <removed>
Connection: keep-alive
Content-Type: application/json
Body:
{
"language": "en",
"name": "Ami Classifier",
"training_data": [
{"classes": ["blue"],"text": "house"},
{"classes": ["blue"],"text": "cube"},
{"classes": ["blue"],"text": "box"},
{"classes": ["red"],"text": "ball"},
{"classes": ["red"],"text": "sphere"},
{"classes": ["red"],"text": "round"}
]
}
This is the response in the last few days:
Content-Type:
Date: Mon, 15 Feb 2016 04:09:17 GMT
Server: -
Set-Cookie: <Ami-removed>
X-Backside-Transport: FAIL FAIL
X-Client-Ip: 54.174.130.249
X-Dp-Watson-Tran-Id: csf_platform_prod_dp02-135442457
X-Global-Transaction-Id: 135442457
BODY view raw
(empty)
Please check the Bluemix status (https://developer.ibm.com/bluemix/support/#status). It came to my attention that there are currently some issues with the cloud infrastructure that is impacting some instances of the NLC training mechanisms.
You should open a support ticket with the Bluemix support team, directions on this are here (https://developer.ibm.com/bluemix/support/#support).
The answer from IBM support is:
"There is some changes in Natural Language Classifier (NLC) service within the last several months. Training classifier from pure REST interface via https://gateway.watsonplatform.net/natural-language-classifier/api/v1/classifiers is no longer available thus you get this error."
I did try it with curl and it works there. However that does not make sense because curl is just making an http call to the same endpoint using the same protocol, so it should be possible to do using a tool like runscope. So far, I haven't been able to replicate the curl call in runscope, but will post it here if I do.
You should add the training data as file attachment. This is how a successful request header looks for my requests:
POST /natural-language-classifier/api/v1/classifiers HTTP/1.1
HOST: gateway.watsonplatform.net
authorization: Basic hereyourownbase64encryptedcredentials==
content-type: multipart/form-data; boundary=----WebKitFormBoundaryiRs1zY19qkzRUzPn
content-length: 2207
------WebKitFormBoundaryiRs1zY19qkzRUzPn
Content-Disposition: form-data; name="training_data"; filename="weather_test_sample.csv"
Content-Type: application/vnd.ms-excel
How hot is it today?,temperature
Is it hot outside?,temperature
Will it be uncomfortably hot?,temperature
Will it be sweltering?,temperature
How cold is it today?,temperature
Is it cold outside?,temperature
Will it be uncomfortably cold?,temperature
Will it be frigid?,temperature
What is the expected high for today?,temperature
What is the expected temperature?,temperature
Will high temperatures be dangerous?,temperature
Is it dangerously cold?,temperature
When will the heat subside?,temperature
Is it hot?,temperature
Is it cold?,temperature
How cold is it now?,temperature
Will we have a cold day today?,temperature
When will the cold subside?,temperature
What highs are we expecting?,temperature
What lows are we expecting?,temperature
Is it warm?,temperature
Is it chilly?,temperature
What's the current temp in Celsius?,temperature
What is the temperature in Fahrenheit?,temperature
Is it windy?,conditions
Will it rain today?,conditions
What are the chances for rain?,conditions
Will we get snow?,conditions
Are we expecting sunny conditions?,conditions
Is it overcast?,conditions
Will it be cloudy?,conditions
How much rain will fall today?,conditions
How much snow are we expecting?,conditions
Is it windy outside?,conditions
How much snow do we expect?,conditions
Is the forecast calling for snow today?,conditions
Will we see some sun?,conditions
When will the rain subside?,conditions
Is it cloudy?,conditions
Is it sunny now?,conditions
Will it rain?,conditions
Will we have much snow?,conditions
Are the winds dangerous?,conditions
What is the expected snowfall today?,conditions
Will it be dry?,conditions
Will it be breezy?,conditions
Will it be humid?,conditions
What is today's expected humidity?,conditions
Will the blizzard hit us?,conditions
Is it drizzling?,conditions
------WebKitFormBoundaryiRs1zY19qkzRUzPn
Content-Disposition: form-data; name="training_metadata"
{"language":"en","name":"My Classifier"}
------WebKitFormBoundaryiRs1zY19qkzRUzPn--

InvalidXmlRequest error for Azure REST API request

I am using the Azure REST API to create an Azure storage account using the documentation at: http://msdn.microsoft.com/en-us/library/hh264518.aspx
I keep getting the 400 error with code InvalidXmlRequest ("The request body's XML was invalid or not correctly specified."). The only related thread seemed to be at Management API - The request body XML was invalid or not correctly specified - I have tried several variations on my request (like removing xml header, removing empty elements from body, etc.) but still see the same error.
There is no requestId in the response header either (to get more info using GET OperationStatus).
The complete RAW request and response (for one of my trials) is below.
Any ideas on what I am missing here?
Request:
POST https://management.core.windows.net/<mysubscriptionid>/services/storageservices HTTP/1.1
x-ms-version: 2011-06-01
Content-Type: application/xml
Host: management.core.windows.net
Content-Length: 350
Expect: 100-continue
<?xml version="1.0" encoding="utf-8"?><CreateStorageServiceInput xmlns="http://schemas.microsoft.com/windowsAzure"><ServiceName>gjhgkjhgkgk</ServiceName><Description /><Label>gjhgkjhgkgk</Label><AffinityGroup /><Location>North Central US</Location><GeoReplicationEnabled>true</GeoReplicationEnabled><ExtendedProperties /></CreateStorageServiceInput>
Response:
HTTP/1.1 400 Bad Request
Content-Length: 228
Content-Type: application/xml; charset=utf-8
Server: Microsoft-HTTPAPI/2.0
Date: Sun, 20 Oct 2013 02:33:08 GMT
<Error xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><Code>InvalidXmlRequest</Code><Message>The request body's XML was invalid or not correctly specified.</Message></Error>
2 things I noticed:
Value in label element should be base64 encoded as mentioned in the documentation here: http://msdn.microsoft.com/en-us/library/windowsazure/hh264518.aspx.
Label Required. A name for the storage account specified as a
base64-encoded string. The name may be up to 100 characters in length.
The name can be used identify the storage account for your tracking
purposes.
Not related to your problem per se but you're trying to create a storage account in North Central US region. Please note that you can't create new resources in North Central and South Central US region.

No output in Firebug when _redirect was called

The code (taken from SO):
// create the logger and log writer
$writer = new Zend_Log_Writer_Firebug();
$logger = new Zend_Log($writer);
// get the wildfire channel
$channel = Zend_Wildfire_Channel_HttpHeaders::getInstance();
// create and set the HTTP response
$response = new Zend_Controller_Response_Http();
$channel->setResponse($response);
// create and set the HTTP request
$channel->setRequest(new Zend_Controller_Request_Http());
// record log messages
$logger->info('info message');
$logger->warn('warning message');
$logger->err('error message');
// insert the wildfire headers into the HTTP response
$channel->flush();
// send the HTTP response headers
$response->sendHeaders();
$this->_redirect('/login/success');
Apparently, all the messages won't appear if I use _redirect(), however, if I use something like
$this->getResponse()->setHeader('Refresh', '0; URL=/login/success');
it will work. So my question is:
What should I do to make sure the messages will appear in my Firebug Console (using _redirect())?
Update 1:
In the Net tab, I can see the messages are in the HEADER, but it's not appearing in my Firebug
Date Wed, 08 Dec 2010 03:42:15 GMT
Server Apache/2.2.16 (Unix) DAV/2 PHP/5.3.3
X-Powered-By PHP/5.3.3
Expires Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma no-cache
X-Wf-Protocol-1 http://meta.wildfirehq.org/Protocol/JsonStream/0.2
X-Wf-1-Structure-1 http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1
X-Wf-1-Plugin-1 http://meta.firephp.org/Wildfire/Plugin/ZendFramework/FirePHP/1.6.2
X-Wf-1-1-1-1 156|[{"Type":"INFO","File":"\/home\/foo\/workspace\/php\/identiti\/application\/modules\/default\/controllers\/LoginController.php","Line":64},"info message"]|
X-Wf-1-1-1-2 159|[{"Type":"WARN","File":"\/home\/foo\/workspace\/php\/identiti\/application\/modules\/default\/controllers\/LoginController.php","Line":65},"warning message"]|
X-Wf-1-1-1-3 158|[{"Type":"ERROR","File":"\/home\/foo\/workspace\/php\/identiti\/application\/modules\/default\/controllers\/LoginController.php","Line":66},"error message"]|
Location /login/success
Content-Length 0
Keep-Alive timeout=5, max=100
Connection Keep-Alive
Content-Type text/html
Update 2:
Apparently it's a bug, confirmed in FirePHP Official Forum. I'll wait untill there's a real fix before I answer this question.
Thanks for the detailed test case.
This is a bug in FirePHP Companion.
Working on a fix. Will let you know
when done (ETA Friday).
Thanks! Christoph
Does enabling the "Persist" option in the Firebug Console tab help?
This is the official answer from the author himself:
I have good and bad news. Logging during redirects works now for FirePHP 1.0 + FirePHP Companion. It will not work for the native Zend Framework implementation until early next year.
To get a working solution, please upgrade to FirePHP 1.0: http://upgrade.firephp.org/
Also see: http://www.christophdorn.com/Blog/2010/11/29/firephp-1-0-in-5-steps/
Instructions for logging during redirects:
http://reference.developercompanion.com/#/Tools/FirePHPCompanion/FAQ/#Redirect Messages
I would suggest using the FirePHP 1.0 library in addition to or instead of the ZF components. This will be much improved early next year.
Please let me know if you get this working.