Openstack Neutron: Adding static Router for the router via rest api - openstack

I am unable to make PUT request for adding static route for the Router .
I got the following error :
{
"NeutronError": {
"message": "Invalid input for external_gateway_info. Reason: Unexpected keys supplied: routes.",
"type": "HTTPBadRequest",
"detail": ""
}
}
and my request payload is :
{
"router": {
"distributed": false,
"external_gateway_info": {
"network_id": "04901d68-eb70-410c-a2ae-e4b77d4e4641",
"enable_snat": true,
"routes": [
{
"destination": "112.112.112.0/24",
"nexthop": "117.97.10.2"
}
]
}
}
}
And, my url is: /routers/{:routerId}
With the same routes, I am able to add static route in open stack neutron but not via API request.
Any improvements in this method?

Please use this below payload.
{
"router": {
"distributed": false,
"routes": [
{
"destination": "172.1.1.0/24",
"nexthop": "177.77.44.11"
}
]
}
}

Related

The LinkedIn Assets API don't show my upload in the linkedin newfeed

I'm using LinkedIn API to upload media to my Linkedin personal profile. I start with registring my image and I get a successful response.
REQUEST
{
"registerUploadRequest":{
"owner":"urn:li:person:xxx",
"recipes":[
"urn:li:digitalmediaRecipe:feedshare-image"
],
"serviceRelationships":[
{
"identifier":"urn:li:userGeneratedContent",
"relationshipType":"OWNER"
}
],
"supportedUploadMechanism":[
"SYNCHRONOUS_UPLOAD"
]
}
}
RESPONSE
{
"value": {
"uploadMechanism": {
"com.linkedin.digitalmedia.uploading.MediaUploadHttpRequest": {
"headers": {
"media-type-family": "STILLIMAGE"
},
"uploadUrl": "xxxx"
}
},
"mediaArtifact": "urn:li:digitalmediaMediaArtifact:(urn:li:digitalmediaAsset:xxx,urn:li:digitalmediaMediaArtifactClass:feedshare-uploadedImage)",
"asset": "urn:li:digitalmediaAsset:xxx"
}
}
Next step I uploaded my image using curl with a valid access token and the uploadUrl
I get a 201 HTTP response but I see nothing in my LinkedIn profile.
also when I check the status of my upload it shows me a success message.
{"recipes":[{"recipe":"urn:li:digitalmediaRecipe:feedshare-image","status":"AVAILABLE"}],"serviceRelationships":[{"relationshipType":"OWNER","identifier":"urn:li:userGeneratedContent"}],"mediaTypeFamily":"STILLIMAGE","created":1606729082880,"id":"C4D22AQE6h5xe3HYYiQ","lastModified":1606729322981,"status":"ALLOWED"}
So why I can't see my upload in the Linkedin timeline, please? I tried with both image and video but nothing is shown in my newsfeed.
Also, I checked my access token and it contains necessary permission: r_liteprofile, w_member_social
Uploading an asset does not make it available on your profile.
Assets API only uploads the image/video and stores it on LinkedIn platform. You can however use this asset to create a UGC Post to see it on your personal/company profile.
To do that, you'll have to use the ugcPosts API. ie call POST https://api.linkedin.com/v2/ugcPosts with
"media": "urn:li:digitalmediaAsset:XXX", from the Assets API response in the payload.
Example:
{
"author": "urn:li:organization:5590506",
"lifecycleState": "PUBLISHED",
"specificContent": {
"com.linkedin.ugc.ShareContent": {
"media": [
{
"media": "urn:li:digitalmediaAsset:XXX", // from the Assets API response
"status": "READY",
"title": {
"attributes": [],
"text": "Sample Video Create"
}
}
],
"shareCommentary": {
"attributes": [],
"text": "Some share text"
},
"shareMediaCategory": "VIDEO"
}
},
"targetAudience": {
"targetedEntities": [
{
"locations": [
"urn:li:country:us",
"urn:li:country:gb"
],
"seniorities": [
"urn:li:seniority:3"
]
}
]
},
"visibility": {
"com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC"
}
}
Reference: https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/ugc-post-api#sample-request

How should a "write" request be structured for Firestore REST API (v1beta1)?

Based on the Google Discovery document, and RPC reference, it appears that the :write resource should be available for Firestore database interactions, but performing such a request to my (POST https://firestore.googleapis.com/v1beta1/projects/[my project]/databases/(default)/documents:write) results in:
[
{
"error": {
"code": 400,
"message": "Invalid value (Object), ",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"description": "Invalid value (Object), "
}
]
}
]
}
}
]
Is this possible? A related SO answer alludes to this being available as a means of field transforms, the same reason I require this, but I cannot construct valid a JSON body to succeed in the request. Currently, variations on the following don't work as expected when trying a minimum successful response:
{
"writes": [
{
"update": {
"name": "projects/{projectId}/databases/[my project]/documents/exampleId",
"fields": {
"example": {
"integerValue": 100
},
"timestamp": {
"nullValue": null
}
},
"transform": {
"document": "projects/[my project]]/databases/(default)/documents/examples/exampleId",
"fieldTransforms": [
{
"fieldPath": "timestamp",
"setToServerValue": "REQUEST_TIME"
}
]
}
}
}
]
}
First of all, note that you should use the v1 version of the REST API, not the betas.
To create a document, you would use the createDocument method, while to update a document you would use the patch one.
For the document creation you should therefore make a POST HTTP Request to the following URL
https://firestore.googleapis.com/v1/projects/<your-project-id>/databases/(default)/documents/<the-desired-collection>
with the following Request body:
{
fields: {
example: {
integerValue: 100
}
}
}
You need to use documents:commit instead of documents:write
also the name field should be in this format:
"name": "projects/projectID/databases/(default)/documents/collectionName/DocumentId"
See this post.

Cloud Firestore REST API - Add server timestamp

I'm using an Arduino with an ESP8266-01 module to upload a value to a Cloud Firestore database using the createDocument API with the following payload:
{
"fields": {
"distance": {
"integerValue": "555"
}
}
}
I do a POST-request to a route like this:
https://firestore.googleapis.com/v1beta1/projects/<MY_PROJECT>/databases/(default)/documents/<SOME_COLLECTION>?key=MY_VERY_SECRET_KEY
That all works, but I would like to add the server timestamp as well. I've found a few answers here on stackoverflow, but I have not been able to make any of them work.
How can I add the server timestamp to the created document? What I want is for the following to be created:
{
"fields": {
"distance": {
"integerValue": "555"
},
"timestamp" : {
"DATETIME": SERVER_TIMESTAMP
}
}
}
Any help appreciated.
What I ended up doing in the end was the following:
A POST request to a route like this:
https://firestore.googleapis.com/v1beta1/projects/<MY_PROJECT>/databases/(default)/documents:commit?&key=<MY_VERY_SECRET_KEY>
With the following payload:
{
"writes": [
{
"update": {
"name": "projects/<MY_PROJECT>/databases/(default)/documents/<COLLECTION_ID>/<DOCUMENT_ID>",
"fields": {
"distance": {
"integerValue": "555"
}
}
}
},
{
"transform": {
"document": "projects/<MY_PROJECT>/databases/(default)/documents/<COLLECTION_ID>/<DOCUMENT_ID>",
"fieldTransforms": [
{
"fieldPath": "servertime",
"setToServerValue": "REQUEST_TIME"
}
]
}
}
]
}
Where I generate a new DOCUMENT_ID (e.g. a GUID) instead of having cloud firestore generate one for me.

Basic Auth header not sent (Swagger)

I have a basic auth secured API but after filling in the authentication credentials, it does not apply to request header. I saw"ERROR Server not found or an error occurred " at swagger editor and "401 Unauthorized" on fiddler.
User Name and Pwd : odata and qtkr47PTM3pmzLyEHNrW4DXhhgyjMfM3CKUZfXdn0tk=
Here is my swagger json
{
"swagger": "2.0",
"info": {
"version": "1.0.0",
"title": "Basic Auth Example",
"description": "An example for how to use Basic Auth with Swagger.\nServer code is available [here](http://navm3.cloudapp.net:90/nav/odata). It's running on NAVM3.\n\n**You can use below User Name and Password for test.**\n* User Name: `ODATA`\n* Password: `qtkr47PTM3pmzLyEHNrW4DXhhgyjMfM3CKUZfXdn0tk=`\n"
},
"host": "navm3.cloudapp.net:90",
"basePath": "/nav/odata",
"schemes": [
"http"
],
"securityDefinitions": {
"basicAuth": {
"type": "basic",
"description": "HTTP Basic Authentication. Works over `HTTP` and `HTTPS`"
}
},
"paths": {
"/": {
"get": {
"security": [
{
"basicAuth": []
}
],
"responses": {
"200": {
"description": "Will send `Authenticated` if authentication is succesful, otherwise it will send `Unauthorized`"
}
}
}
}
}
}
i had the same problem, but the problem was in nodeJS back-end.
If you are using NodeJS, probably the problem it is with CORS. You should enable CORS in NodeJS with Express and everything will work.
To enable the CORS in nodeJS you can add the below code, before of the routes.
var app = express();
app.use(function(req, res, next) {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, UPDATE, DELETE, OPTIONS');
res.setHeader('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept, Authorization');
next();
});
try to replace the following part:
"securityDefinitions": {
"basicAuth": {
"type": "basic",
"description": "HTTP Basic Authentication. Works over `HTTP` and `HTTPS`"
}
},
with the following
"securityDefinitions": {
"basicAuth": {
"type": "http",
"scheme": "basic"
}
},
keeping the rest as is
here is the reference https://swagger.io/docs/specification/authentication/basic-authentication/

google datastore api explorer example

I am trying to understand
https://developers.google.com/apis-explorer/#p/datastore/v1beta1/datastore.datasets.blindWrite
but I always get
503 Service Unavailable
{
"error": {
"errors": [
{
"domain": "global",
"reason": "backendError",
"message": "Backend Error"
}
],
"code": 503,
"message": "Backend Error"
}
}
Can you provide a example as simple as possible I can paste to verify it actually works?
I tried something like this.
{
"mutation": {
"insertAutoId": [
{
"key": {
"path": [
{
"kind": "person",
"name": "gert"
}
]
}
}
]
}
}
Assuming that you followed one of the first two activation flows described in the documentation. And created the project recently, an App Engine application should be already associated with your project.
You need to:
Click Authorize your request using OAuth 2.0
Leave https://www.googleapis.com/auth/userinfo.email scope checked
Add https://www.googleapis.com/auth/datastore under Add additional scopes (optional)
Click Authorize and grant the permission
Specify the datasetId parameter (same as your project-id)
Use insert or upsert instead of insertAutoId if the key is complete (kind w/ name or id).
Example:
POST https://www.googleapis.com/datastore/v1beta1/datasets/my-dataset-id/blindWrite...
Content-Type: application/json
Authorization: Bearer ...
X-JavaScript-User-Agent: Google APIs Explorer
{
"mutation": {
"insert": [
{
"key": {
"path": [
{
"kind": "Foo",
"name": "iamfoo"
}
]
}
}
]
}
}
200 OK
{
"kind": "datastore#blindWriteResponse",
"mutationResult": {
"indexUpdates": 1
}
}

Resources