Ocelot swagger redirection issue - swagger

I am trying to implement Ocelot/Swagger/MMLib and .net microservices on my Windows 2019 server.
Everything is working fine, I can call each of the microservices correctly through the API gateway using postman, but I would like to display the swagger documentation as the API is going to be used by a third party.
If I use the ip address/port number I get the correct page displayed, with my microservice definitions. However if I reroute this to a physical url (eg https://siteaddress.com/path/swagger.index.html) I get the main swagger document but a 'Failed to load API definition' error, followed by 'Fetch error undefined /swagger/docs/v1/test.
The network page of my browser inspection gives a 'Http Error 404.0 Not Found'. The requested url is 'https://siteaddress.com:443/swagger/docs/v1/test'.
My ocelot.json is:
{
"Routes": [
{
"DownstreamPathTemplate": "/api/v1/TestSvc/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "test.api",
"Port": "80"
}
],
"UpstreamPathTemplate": "/api/v1/TestSvc/{everything}",
"UpstreamHttpMethod": [ "POST" ],
"SwaggerKey": "test"
}
...
],
"SwaggerEndPoints": [
{
"Key": "test",
"Config": [
{
"Name": "Test API",
"Version": "v1",
"Url": "http://test.api:80/swagger/v1/swagger.json"
}
]
}
...
]
}
I have tried changing paths in ocelot.json and startup.cs. I can see nothing in the MMLib documentation regarding this scenario, which is surely common in deploying these sites.
Suggestion on where to go next appreciated.
Page with ipaddress and port number
Page with physical address and error message

Related

Why is the Azure Devops API telling me that I must have these parameters for my Push request when I already do?

I'm trying to make a Git push request to our Azure Devops server via the API. The address is https://MYSITE.visualstudio.com/MYPROJECT/_apis/git/repositories/2b34d4f7-2c1f-42e7-8861-u0ba34f72b40/pushes?api-version=5.1 and the body is as follows:
{
"commits": [
{
"comment": "Just a dummy commit",
"changes": [
{
"changeType": "edit",
"item": {
"path": "/src/MYPROJECT/MYPROJECT.csproj"
},
"newContent": {
"content": "beans",
"contentType": "rawText"
}
}
]
}
],
"refUpdates": [
{
"name": "refs/heads/TestDummyPRs/upgradeProjectToLatest",
"oldObjectId": "058da4f3328cb1048cb43faf3b5158bc3b025615"
}
]
}
I'm getting the following error:
Web Request Failed after 4 attempts. Request: https://MYSITE.visualstudio.com/MYPROJECT/_apis/git/repositories/2b34d4f7-2c1f-42e7-8861-u0ba34f72b40/pushes?api-version=5.1. Status: BadRequest. Response: Invalid status code [BadRequest]. Response: {"$id":"1","innerException":null,"message":"The parameters are incorrect. A posted push must contain exactly one commit and one refUpdate.\r\nParameter name: newPush","typeName":"Microsoft.TeamFoundation.SourceControl.WebServer.InvalidArgumentValueException, Microsoft.TeamFoundation.SourceControl.WebServer","typeKey":"InvalidArgumentValueException","errorCode":0,"eventId":0}
"A posted push must contain exactly one commit and one refUpdate" doesn't seem entirely reasonable as that's exactly what I have in my body. Does anybody know what might be going on here?
Note that I am having no issues making other web requests, such as creating branches or retrieving file contents.
I expected my web request to proceed smoothly, and to create a Push containing the specified commit to the specified refUpdate.
I have made a manual push for via the Azure Devops web interface and caught the network traffic, and I grabbed the following JSON request out of it:
{
"commits": [
{
"changes": [
{
"changeType": 2,
"item": {
"path": "/src/MYPROJECT/MYPROJECT.csproj"
},
"newContent": {
"content": "beans",
"contentType": 0
}
}
],
"comment": "Just a dummy commit"
}
],
"refUpdates": [
{
"name": ""refs/heads/TestDummyPRs/upgradeProjectToLatest",
"oldObjectId": "058da4f3328cb1048cb43faf3b5158bc3b025615"
}
]
}
This seems to be meaningfully identical to the Push I'm making from my code, other than the enum fields using numerical values instead of text. I have tried my code with numerical values for enums, but that didn't change anything about the error.
I found the issue. The web request from my application was being sent with UTF-16 encoding, whereas Postman had defaulted to UTF-8 encoding. I changed my application to use UTF-8 and it worked.

chronograf: Not able to add default influxDB connection when using OAuth 2.0

I configured Chronograph to use generic OAuth 2.0 (using cloud foundry UAA). Users authentication works fine but the problem is that the default influxdb connection is not taken into consideration. In fact this configuration works:
chronograf --log-level="debug" --resources-path="/usr/share/chronograf/resources" --influxdb-url="http://influxDB.log.database:8086" --influxdb-username="usename" --influxdb-password="pass"
here is the content of /usr/share/chronograf/resources folder:
influxdb.src:
{
"id": "9999",
"name": "MyInfluxDB",
"username": "user1,
"password": "password1",
"url": "http://influxDB.log.database:8086",
"type": "influx",
"insecureSkipVerify": true,
"default": true,
"telegraf": "telegraf.autogen",
"organization": "Default"
}
Both connections are automatically created when chronoraf starts :
MyInfluxDB
http://influxDB.log.database:8086
but When I run chronograf with the following options (To use OAuth 2.0 and create an influxdb connection) :
export TOKEN_SECRET="token_secret"; export JWKS_URL="https://uaa/token_keys"; export PUBLIC_URL="http://chronograf:8888"; chronograf --log-level="debug" --resources-path="/usr/share/chronograf/resources" --generic-name="generic" --generic-client-id="id" --generic-client-secret="secret" --generic-scopes="openid" --generic-auth-url="https://uaa/oauth/authorize" --generic-token-url="https://uaa/oauth/token" --generic-api-url="https://uaa/userinfo"
The OAuth 2.0 works fine but once redirected to the chronograf dashboard I cannot see the connections and even when I created a connection manually and I log in I cannot found any connection that is created automatically on startup as wanted.
the field organization needs an id. The id for the Default orginization uses a lower case d. If you change your src file to,
{
"id": "9999",
"name": "MyInfluxDB",
"username": "user1,
"password": "password1",
"url": "http://influxDB.log.database:8086",
"type": "influx",
"insecureSkipVerify": true,
"default": true,
"telegraf": "telegraf.autogen",
"organization": "default"
}
It should now work.
you can see where the id is defined in their source here https://github.com/influxdata/chronograf/blob/9d8a49ba0ef8131cdce22d73718859f55f434db2/bolt/organizations.go#L20

Creating direct HTTP-request through YouTube Analytics API v2 to view the videos of the channel that were embedded on external sites

I am quite new in using Google APIs. So, the problem is that I am administrator of the YouTube channel (not the owner). And I would like to get the straffic sources that were embedded on external websites. So, I've created new project and formed a request through Google APIs Explorer. Here it is:
https://youtubeanalytics.googleapis.com/v2/reports?dimensions=insightTrafficSourceDetail&endDate=2018-12-12&filters=insightTrafficSourceType%3D%3DEXT_URL&ids=channel%3D%3D{MY_CHANNEL}&maxResults=25&metrics=views&sort=-views&startDate=2014-05-01&key={MY_API_KEY}
Here is the result:
200
- Show headers -
{
"kind": "youtubeAnalytics#resultTable",
"columnHeaders": [
{
"name": "insightTrafficSourceDetail",
"columnType": "DIMENSION",
"dataType": "STRING"
},
{
"name": "views",
"columnType": "METRIC",
"dataType": "INTEGER"
}
],
"rows": [
[
"vk.com",
2399
],
[
"unknown",
872
],
[
"yandex.ru",
23
]
But when I try to write the request into the browser address bar directly, it says:
{
"error": {
"code": 401,
"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"errors": [
{
"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"domain": "global",
"reason": "unauthorized"
}
],
"status": "UNAUTHENTICATED"
}
}
I pushed into the {API_KEY} field from here
But, unfortunately, the result is such as provided above. What am I doing wrong? Can you provide the step-by-step instruction to get the right HTTP-request for my aim, as I counld'nt find it? Thank you!

Simple swagger specification, to retrieve an html web page

I'm new to swagger, and I'm trying to make a very simple specification, with only a get method in order to retrieve a web page, this is the code:
{
"swagger": "2.0",
"info": {
"title": "example",
"description": "Sample api to retrieve a web page.",
"version": "0.1"
},
"host":"example.org", #"localhost:8080",
"schemes": [
"https"
],
"paths": {
"/":{
"get":{
"summary":"Return the web page.",
"description":"",
"produces":["text/html"],
"responses":{
"200":{
"description":"OK",
},
"400":{
"description":"Bad request"
},
"404":{
"description":"Not Found"
}
}
}
}
}
}
I'm using the swagger online editor.
Unfortunately when I execute the request, it did not return the web page and no one of the status code that I have implemented in the specification, it return me in the detail section the error:
TypeError: Failed to fetch
Someone can tell me where I'm wrong?
Thank you.
For the "Try it out" button to work in the Swagger online editor, your API endpoints must be CORS-enabled. That is, your server (example.org or localhost:8080) must be configured to return certain response headers that would allow editor.swagger.io to make cross-domain requests to your server. This is explained in more details here:
https://github.com/swagger-api/swagger-ui#cors-support
The way to configure CORS depends on the server/framework used to host the app. This page has instructions for some common web servers:
https://enable-cors.org/server.html

'eventNotification' url is not being called

I am integrating DocuSign with our application. In testing phase we got a server with public IP and port (8086). On this port I have published my asp.net mvc web api and my url becomes:
http://XXX.XXX.XXX.XXX:8086/api/DocuSign/DocuSignDocumentStatus.
This url is going to be called from DocuSign whenever my document status changes.
Our network team has allowed access to following IPs for inbound access to this public IP/URL:
www.docusign.net 209.67.98.12
mailsea.docusign.net 209.67.98.59
NA2
na2.docusign.net 206.25.247.140
mailch.docusign.net 206.25.247.155
EU1
eu1.docusign.net 206.25.247.144
mailch.docusign.net 206.25.247.155
DAL/DR
demo.docusign.net 209.46.117.172
preview.docusign.net 209.46.117.174
mailda.docusign.net 209.46.117.17
I got this from the connect service reference pdf.
Whenever I am uploading the document from signing via docuSign web api and I am also sending this url with the request. I have checked - rechecked many times that my json request being created is correct (pasting it below):
{
"status": "sent",
"emailBlurb": "",
"emailSubject": "DocuSign API - Signature Request on Document Call",
"documents": [
{
"name": "someDocument.xls",
"documentId": "1"
}
],
"recipients": {
"signers": [
{
"recipientId": "1",
"email": "john.doe#someCompany.com",
"name": "John Doe",
"tabs": {
"signHereTabs": [
{
"xPosition": "100",
"yPosition": "100",
"documentId": "1",
"pageNumber": "1"
}
]
},
"routingOrder": "1"
}
],
"carbonCopies": [
{
"recipientId": "2",
"email": "some1.recipient#someCompany.com",
"name": "Some1 Recipient"
},
{
"recipientId": "3",
"email": "some2.recipient#someCompany.com",
"name": "Some2 Recipient"
},
{
"recipientId": "4",
"email": "some3.recipient#someCompany.com",
"name": "Some3 Recipient"
}
]
},
"eventNotification": {
"url": "http://XXX.XXX.XXX.XXX:8086/api/DocuSign/DocuSignDocumentStatus",
"loggingEnabled": true,
"requireAcknowledgement": true,
"includeDocuments": false,
"envelopeEvents": [
{
"envelopeEventStatusCode": "Completed"
},
{
"envelopeEventStatusCode": "Declined"
}
]
}
}
I am able successfully upload the document, emails are being sent successfully to all signers. Document being signed BUT DocuSign for some reason is not able to call my url with the status of the document. Please help. Let me know if you guys need any more information.
As specified by the Answer & subsequent Comment in this other question:
Regardless of whether you're using DocuSign Connect (configured at the account level) or using eventNotification (specified at the Envelope level), DocuSign will only publish messages to the "standard/default" ports:
In the DocuSign demo environment (demo.docusign.net) DocuSign Connect will publish to either port 80 (http) or port 443 (https). If the URL starts with "http", Connect will attempt to publish to port 80. If the URL starts with "https", Connect will attempt to publish to port 443.
In the DocuSign production environment (www.docusign.net), DocuSign Connect will only publish to port 443 (https). Publishing to port 80 (http) is not supported in the production environment -- the listener endpoint must be https.
Therefore, I'd suggest that you remove the port number from the URL that you've specified for "eventNotification", and ensure that your listener endpoint is located at either port 80 (for demo) or port 443 (for demo or prod).

Resources