How to change the cache-control in swagger-ui - swagger

In swagger-ui the header parameter for cache-control is set to no-cache. Is there a way to change this to a different cache-control type? such as public or private.
{
"correlationid": "b58df02a-6690-4f66-8335-73ad26f8cea3",
"pragma": "no-cache",
"date": "Tue, 04 Jun 2019 02:47:48 GMT",
"server": "Microsoft-IIS/10.0",
"x-powered-by": "ASP.NET",
"content-type": "application/json; charset=utf-8",
"cache-control": "no-cache",
"content-length": "536827",
"expires": "-1"
}
I would like to be able to send different header parameters so i can model different outcomes.

Related

Power Automate / Twilio : HTTP POST Error

I'm not sure what I've messed up, but I'm receiving this error when attempting to send a POST request from Power Automate to a Twilio Flow.
Was able to trigger the Twilio Flow from PowerShell, but cannot replicate on Power Automate.
{
"code": 20001,
"message": "Missing required parameter To in the post body",
"more_info": "https://www.twilio.com/docs/errors/20001",
"status": 400
}
input
output
http request post
This ended up working for me.
Change Content-Type value to
application/x-www-form-urlencoded; charset=utf-8
Change Body value to
To=%2B12223334444&From=%2B15556667777
12223334444 = Send To #
15556667777 = Send From # (Twilio Phone # assigned the Flow)
Re: Using HTTP POST with Twilio
INPUT
{
"uri": "https://studio.twilio.com/v2/Flows/##################################/Executions",
"method": "POST",
"headers": {
"content-type": "application/x-www-form-urlencoded; charset=utf-8"
},
"authentication": {
"username": "**********************************",
"password": "*sanitized*",
"type": "Basic"
},
"body": "To=%2B12223334444&From=%2B15556667777"
}
OUTPUT
{
"statusCode": 201,
"headers": {
"Connection": "keep-alive",
"Twilio-Concurrent-Requests": "1",
"Twilio-Request-Id": "##################################",
"Twilio-Request-Duration": "0.055",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "Accept, Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since",
"Access-Control-Allow-Methods": "GET, POST, DELETE, OPTIONS",
"Access-Control-Expose-Headers": "ETag",
"Access-Control-Allow-Credentials": "true",
"X-Shenanigans": "none",
"X-Home-Region": "us1",
"X-API-Domain": "studio.twilio.com",
"Strict-Transport-Security": "max-age=31536000",
"Date": "Tue, 08 Jun 2021 14:04:24 GMT",
"X-Powered-By": "AT-5000",
"Content-Length": "707",
"Content-Type": "application/json"
},
"body": {
"status": "active",
"date_updated": null,
"contact_channel_address": "+12223334444",
"account_sid": ""**********************************",",
"url": "https://studio.twilio.com/v2/Flows/##################################/Executions/##################################",
"context": {},
"sid": "##################################",
"date_created": "2021-06-08T14:04:23Z",
"flow_sid": "##################################",
"links": {
"steps": "https://studio.twilio.com/v2/Flows/##################################/Executions/##################################/Steps",
"execution_context": "https://studio.twilio.com/v2/Flows/##################################/Executions/##################################/Context"
}
}
}

Ruby on Rails get body object from fcm response

I have implemented fcm for push notification in windows ruby on rails. but I'm getting response of send() that is in following format. I need only body attribute's value.I'm pretty new to ruby on rails. please guide how can i achieve it.
fcm = FCM.new(server_key)
options = {
priority: "high",
# collapse_key: "updated_score",
notification: {
title: "Hi Android",
body: "Hi, Worked perfectly"
}
}
response = fcm.send([device_token], options)
This is my response
{
"success": true,
"data": {
"body": "{\"multicast_id\":8218758506962978728,\"success\":1,\"failure\":0,\"canonical_ids\":0,\"results\":[{\"message_id\":\"0:1514875371230492%ebb60861ebb60861\"}]}",
"headers": {
"content-type": [
"application/json; charset=UTF-8"
],
"date": [
"Tue, 02 Jan 2018 06:42:51 GMT"
],
"expires": [
"Tue, 02 Jan 2018 06:42:51 GMT"
],
"cache-control": [
"private, max-age=0"
],
"x-content-type-options": [
"nosniff"
],
"x-frame-options": [
"SAMEORIGIN"
],
"x-xss-protection": [
"1; mode=block"
],
"server": [
"GSE"
],
"alt-svc": [
"hq=\":443\"; ma=2592000; quic=51303431; quic=51303339; quic=51303338; quic=51303337; quic=51303335,quic=\":443\"; ma=2592000; v=\"41,39,38,37,35\""
],
"accept-ranges": [
"none"
],
"vary": [
"Accept-Encoding"
],
"connection": [
"close"
]
},
"status_code": 200,
"response": "success",
"canonical_ids": [],
"not_registered_ids": []
}
}
You can follow ruby OpenStruct library, it's something like this
object = JSON.parse(response, object_class: OpenStruct)
Then you can find based on object value and very nicely explain here
Hope to help
suppose your response is hash
body = hash[:data][:body].gsub(/[\"]/,"")
and out put will be like this: -
"{multicast_id:8218758506962978728,success:1,failure:0,canonical_ids:0,results:[{message_id:0:1514875371230492%ebb60861ebb60861}]}"

Microsoft Graph OneDrive invite fails when inviting group alias

We are seeing what appears to be a change in the behavior of the Graph API. Our code, which grants access for an Excel workbook in OneDrive to a specific Security Group, is now failing where it used to succeed.
Request:
POST https://graph.microsoft.com/V1.0/groups/d4826b5d-4106-40a6-97e0-3826dff58e17/drive/root:/sageData/_verbs.xlsx:/invite HTTP/1.1
Accept: application/json
Authorization: Bearer <<token omitted>>
Content-Type: application/json; charset=utf-8
Host: graph.microsoft.com
Content-Length: 127
Expect: 100-continue
Connection: Keep-Alive
{
"recipients": [{
"alias": "d536e908-60cb-4558-8b3a-38f033d6508a"
}],
"requireSignIn": true,
"sendInvitation": false,
"roles": ["Write"]
}
Response:
HTTP/1.1 404 Not Found
Cache-Control: private
Content-Type: application/json
request-id: 48f148b6-0c15-410e-b29d-bef5880c7007
client-request-id: 48f148b6-0c15-410e-b29d-bef5880c7007
x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"North Europe","Slice":"SliceB","Ring":"NA","ScaleUnit":"001","Host":"AGSFE_IN_14","ADSiteName":"DUB"}}
Duration: 981.5167
Date: Wed, 15 Nov 2017 13:05:50 GMT
Content-Length: 247
{
"error": {
"code": "itemNotFound",
"message": "One of the provided recipients could not be found",
"innerError": {
"request-id": "48f148b6-0c15-410e-b29d-bef5880c7007",
"date": "2017-11-15T13:05:51"
}
}
}
However, we can see that "recipient"" (which is the Security Group id) does indeed exist:
GET https://graph.microsoft.com/v1.0/groups/d536e908-60cb-4558-8b3a-38f033d6508a
Response
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#groups/$entity",
"id": "d536e908-60cb-4558-8b3a-38f033d6508a",
"deletedDateTime": null,
"classification": null,
"createdDateTime": "2017-11-15T12:42:01Z",
"description": "{\"datasetIdentifier\":\"4122e61b-d5c1-4a58-9068-dfdeda9e8278\",\"roleIdentifier\":\"FullAccess\",\"isSageMetadata\":true,\"type\":\"Role\"}",
"displayName": "Sage - Pete - All Apps & Add-Ins",
"groupTypes": [],
"mail": null,
"mailEnabled": false,
"mailNickname": "Sage-Pete-AllApps-Add-Ins",
"onPremisesLastSyncDateTime": null,
"onPremisesProvisioningErrors": [],
"onPremisesSecurityIdentifier": null,
"onPremisesSyncEnabled": null,
"proxyAddresses": [],
"renewedDateTime": "2017-11-15T12:42:01Z",
"securityEnabled": true,
"visibility": null
}
The documentation states the recipient property we are posting should be "email" whereas we have used "alias" up to this point. If we change to "email" then it works.
However, that seems incorrect, according to the documentation we should use alias:
"The alias of the domain object, for cases where an email address is unavailable (e.g. security groups)."
Has anyone else encountered this behaviour?
What you're submitting as an alias is actually an objectId. The alias in this case would be the object's mailNickname (i.e. Sage-Pete-AllApps-Add-Ins).
Either of these should work:
{
"recipients": [{
"objectId": "d536e908-60cb-4558-8b3a-38f033d6508a"
}],
"requireSignIn": true,
"sendInvitation": false,
"roles": ["Write"]
}
or
{
"recipients": [{
"alias": "Sage-Pete-AllApps-Add-Ins"
}],
"requireSignIn": true,
"sendInvitation": false,
"roles": ["Write"]
}

Duplicate grant_type parameter Uber API

I'm trying to get OAuth access to Uber, using Cortana's Connected account.
All necessary for authentication data, a.k.a. auth url, token url, client secret, etc. was taken from Uber API description and passed to Cortana, so she must do all low-level job for me.
But when I'm trying to login in to uber, I receving such answer:
"error": "The token response status code was not 200.",
"serviceRequest": {
"Host": "login.uber.com",
"Headers": {
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": "Basic VXF6cGVzeWVwYXFPZDBrc0FsUTh3U0dTHFvb2k6TFg0TWFhVDRwU0NFNlM3ZDJVMGJSdlU0VnJhTnRncFJPVlo4UkNqQg=="
},
"Method": "POST",
"Path": "/oauth/v2/token",
"UrlParameters": {
"redirect_uri": "https://www.bing.com/agents/oauth",
"grant_type": "authorization_code",
"code": "some code private here :)"
},
"PostData": "redirect_uri=https%3a%2f%2fwww.bing.com%2fagents%2foauth&grant_type=authorization_code&code=SOME_AUTHORIZATION_CODE"
},
"serviceResponse": {
"Headers": {
"Connection": "keep-alive",
"Pragma": "no-cache",
"X-Uber-App": "login",
"Strict-Transport-Security": "max-age=604800",
"X-Content-Type-Options": "nosniff",
"X-XSS-Protection": "1; mode=block",
"Cache-Control": "no-store",
"Date": "Sat, 28 Oct 2017 10:30:57 GMT",
"Set-Cookie": "session=421370309da06baf_59f45c61.RKb0a7144yyiV9HlZgssA5ZvSqE; Domain=login.uber.com; Secure; HttpOnly; Path=/",
"Server": "nginx",
"Content-Length": "84",
"Content-Type": "application/json"
},
"StatusCode": 400,
"ResponseData": "{\"error_description\": \"Duplicate grant_type parameter.\", \"error\": \"invalid_request\"}"
},
As you can see, in property ResponseData I have an error: Duplicate grant_type parameter.
What could it be?
Do you need to repeat the auth parameters for the token request as URL params when they are included in the POST data. I am assuming that "some code private here :)" and SOME_AUTHORIZATION_CODE are the same.

youtube-v3-api Channel list error

When I use the test form on the page https://developers.google.com/youtube/v3/docs/channels/list to get my upload ID I do not get the upload ID information in the output.
200 OK
- HIDE HEADERS -
cache-control: private, max-age=0, must-revalidate, no-transform
content-encoding: gzip
content-length: 184
content-type: application/json; charset=UTF-8
date: Sun, 20 Sep 2015 05:09:05 GMT
etag: "jOXstHOM20qemPbHbyzf7ztZ7rI/Z9n3n2b5RwRnE9WNo9TXpCBWbY4"
expires: Sun, 20 Sep 2015 05:09:05 GMT
server: GSE
vary: Origin, X-Origin
{
"kind": "youtube#channelListResponse",
"etag": "\"jOXstHOM20qemPbHbyzf7ztZ7rI/Z9n3n2b5RwRnE9WNo9TXpCBWbY4\"",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 5
},
"items": [
]
}
The command being used to generate this request is
GET https://www.googleapis.com/youtube/v3/channels?part=contentDetails&forUsername=StraconisChannel
The part that confuses me is I'm doing the same thing as suggested by a tutorial I was following, the only thing I'm changing is the channel name and using my channel name instead. His output looks like this:
200 OK
- HIDE HEADERS -
cache-control: private, max-age=0, must-revalidate, no-transform
content-encoding: gzip
content-length: 350
content-type: application/json; charset=UTF-8
date: Sun, 20 Sep 2015 05:15:54 GMT
etag: "jOXstHOM20qemPbHbyzf7ztZ7rI/ih1aNGvKXcChCR4os4iGDwWDjmQ"
expires: Sun, 20 Sep 2015 05:15:54 GMT
server: GSE
vary: Origin, X-Origin
{
"kind": "youtube#channelListResponse",
"etag": "\"jOXstHOM20qemPbHbyzf7ztZ7rI/ih1aNGvKXcChCR4os4iGDwWDjmQ\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 5
},
"items": [
{
"kind": "youtube#channel",
"etag": "\"jOXstHOM20qemPbHbyzf7ztZ7rI/vDeq-1ACEYq89nbPsEZtYt0KNW0\"",
"id": "UC29ju8bIPH5as8OGnQzwJyA",
"contentDetails": {
"relatedPlaylists": {
"likes": "LL29ju8bIPH5as8OGnQzwJyA",
"favorites": "FL29ju8bIPH5as8OGnQzwJyA",
"uploads": "UU29ju8bIPH5as8OGnQzwJyA"
},
"googlePlusUserId": "111890735795696959293"
}
}
]
}
The request used for his results:
GET https://www.googleapis.com/youtube/v3/channels?part=contentDetails&forUsername=techguyweb
I activated the Authorization using OAuth 2.0 so I'm not sure what the issue is.
Edit
A comment stated because it was my youtube username and not my google plus account name. I forgot to put this in to provided information as well. Which is the same result.
200 OK
- HIDE HEADERS -
cache-control: private, max-age=0, must-revalidate, no-transform
content-encoding: gzip
content-length: 184
content-type: application/json; charset=UTF-8
date: Sun, 20 Sep 2015 14:10:14 GMT
etag: "jOXstHOM20qemPbHbyzf7ztZ7rI/Z9n3n2b5RwRnE9WNo9TXpCBWbY4"
expires: Sun, 20 Sep 2015 14:10:14 GMT
server: GSE
vary: Origin, X-Origin
{
"kind": "youtube#channelListResponse",
"etag": "\"jOXstHOM20qemPbHbyzf7ztZ7rI/Z9n3n2b5RwRnE9WNo9TXpCBWbY4\"",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 5
},
"items": [
]
}
It returns the correct response if you specify channel ID instead of channel name (I got the information via HTTP request but it should work the same for the way you're trying to get the response).
{
"kind": "youtube#channelListResponse",
"etag": "\"jOXstHOM20qemPbHbyzf7ztZ7rI/pZlhvAUywQ74J9YlQvQ1UqIqanc\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#channel",
"etag": "\"jOXstHOM20qemPbHbyzf7ztZ7rI/iPoXCMXPqVZgATwZUSDCg0QqeCM\"",
"id": "UCoyAhNWQms1nSgGbI3rVebQ",
"snippet": {
"title": "StraconisChannel",
"description": "",
"publishedAt": "2015-09-08T22:33:23.000Z",
"thumbnails": {
"default": {
"url": "https://yt3.ggpht.com/-Yyqu34zJ9zs/AAAAAAAAAAI/AAAAAAAAAAA/tjDa1pW2Smw/s88-c-k-no/photo.jpg"
},
"medium": {
"url": "https://yt3.ggpht.com/-Yyqu34zJ9zs/AAAAAAAAAAI/AAAAAAAAAAA/tjDa1pW2Smw/s240-c-k-no/photo.jpg"
},
"high": {
"url": "https://yt3.ggpht.com/-Yyqu34zJ9zs/AAAAAAAAAAI/AAAAAAAAAAA/tjDa1pW2Smw/s240-c-k-no/photo.jpg"
}
},
"localized": {
"title": "StraconisChannel",
"description": ""
},
"country": "US"
},
"contentDetails": {
"relatedPlaylists": {
"uploads": "UUoyAhNWQms1nSgGbI3rVebQ"
},
"googlePlusUserId": "108236998864115482919"
}
}
]
}
Make sure you have verified your YouTube channel and connected your channel to a Google+ Page or Profile.

Resources