Drupal-8 restful webservices only delivering HTML - web-services

I have a freshly configured Drupal 8.0 beta 12 with HAL, HTTP Basic Authentication, RESTful Web Services and Serialization modules enabled. The installation is in a subfolder (D8_beta12). When I access the web services for the first page created (id=1) like
curl -H "Accept: application/json" --request GET http://localhost/d8_beta12/node/1
DRUPAL only delivers HTML format of the node. I have tried to configure via REST UI to JSON only but that didn't help. DRUPAL would answer the requests even if the web services are disabled.
Its probably the user, who's sitting in front of DRUPAL, who is the problem (me) - but I don't get it. Any help deply appreciated - I have been working hours on this, reviewing all of DRUPALs forums and here as well.
Thanks,
Andi

I was getting the same and found a note about it https://drupal.stackexchange.com/questions/161421/d8-services-errors-no-route-found-for-the-specified-formats
So I updated the request to :
node/1?_format=json
Update: Found note about it in a webchick slideshare:
http://www.slideshare.net/webchickenator/plain-english-guide-to-drupal-8-criticals/51

Please try replacing aaplication/json with application/hal+json.
curl -H "Accept: application/hal+json" --request GET http://localhost/d8_beta12/node/1
You may also like to go through this precise tutorial.

from postman if you are trying or from other rest api you are trying make sure you follow below format
http://localhost/da/drupal819/node/253?_format=json
output
{
"nid": [
{
"value": "253"
}
],
"uuid": [
{
"value": "6f255c93-6886-4c38-b4cb-c40469073d1c"
}
],
"vid": [
{
"value": "253"
}
],
"langcode": [
{
"value": "en"
}
],
"type": [
{
"target_id": "article",
"target_type": "node_type",
"target_uuid": "ee2c7b5e-d57e-4714-9193-daff153c63ff"
}
],
"title": [
{
"value": "Commodo Pagus Quia"
}
],
"uid": [
{
"target_id": "14",
"target_type": "user",
"target_uuid": "0b8602ec-8003-4e3d-8406-5bd53e47df71",
"url": "/da/drupal819/user/14"
}
],
"status": [
{
"value": "1"
}
],
"created": [
{
"value": "1474126412"
}
],
"changed": [
{
"value": "1474175616"
}
],
"promote": [
{
"value": "1"
}
],
"sticky": [
{
"value": "0"
}
],
"revision_timestamp": [
{
"value": "1474175616"
}
],
"revision_uid": [
{
"target_id": "14",
"target_type": "user",
"target_uuid": "0b8602ec-8003-4e3d-8406-5bd53e47df71",
"url": "/da/drupal819/user/14"
}
],
"revision_log": [],
"revision_translation_affected": [
{
"value": "1"
}
],
"default_langcode": [
{
"value": "1"
}
],
"path": [],
"body": [
{
"value": "Duis revitas melior paulatim quibus quidne rusticus velit vereor.\n\n",
"format": "plain_text",
"summary": "Duis vitas melior paulatim quibus quidne rusticus velit vereor.\n\n"
}
],
"comment": [
{
"status": "2",
"cid": "165",
"last_comment_timestamp": "1474175616",
"last_comment_name": "",
"last_comment_uid": "13",
"comment_count": "1"
}
],
"field_image": [
{
"target_id": "248",
"alt": "Diam iriure neo quadrum refero valetudo verto ymo.",
"title": "Os patria refoveo si valetudo.",
"width": "225",
"height": "526",
"target_type": "file",
"target_uuid": "02050136-7a51-4183-9c28-7d7cc793183a",
"url": "http://localhost/da/drupal819/sites/default/files/2016-09/gen8C.tmp.jpeg"
}
],
"field_tags": []
}
you can try other format as well
1) http://localhost/da/drupal819/node/253?_format=hal_json
2) http://localhost/da/drupal819/node/253?_format=xml
to support all above format you need to make that format support from rest configuration from admin panel
and even you need to provide get permission for rest call from permission page for anonymous user.

Related

AWS API Gateway (REST) - Request Validation passes even when there is unknown property

I have an API gateway with the following schema:
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://swagger.io/terms/",
"contact": {
"email": "apiteam#swagger.io"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"paths": {
"/pet": {
"post": {
"summary": "Add a new pet to the store",
"description": "",
"operationId": "addPet",
"consumes": [
"application/json",
"application/xml"
],
"produces": [
"application/xml",
"application/json"
],
"parameters": [
{
"in": "body",
"name": "body",
"description": "Pet object that needs to be added to the store",
"required": true,
"schema": {
"$ref": "#/definitions/Pet"
}
}
],
"responses": {
"405": {
"description": "Invalid input"
}
}}
}},
"definitions": {
"Pet": {
"required": ["id", "name"],
"type": "object",
"properties": {
"id": {
"type": "integer",
"description": "Id of the pet",
"example": 123
},
"name": {
"type": "string",
"description": "Name of the pet",
"example": "Jammy"
},
"nickname": {
"type": "string",
"description": "Nickname of the pet",
"example": "Jam"
}
}
}
}
}
When I send a request body with fields which are not present in the schema, I don't get 400 response from API gateway. I have applied the configuration to Validate body, headers, query string.
Is this an open issue in API gateway? Or am I missing something?
So with swagger v2 and openapiv3 specs the default behavior is to accept all additional properties that your spec does not define. If you include the required pet id and name and additional unused propertues like foo and bar, you post should succeed.
If you want more strict validation that fails when additional properties are sent then set additionalProperties to false in your pet schema or do that and change the spec version to 3.x.x

Superset API Request Filters

I'm attempting to retreive a list of dashboards via the superset API which have a specific owner. I've attempted many unsuccessful ways to compose the request:
/api/v1/dashboard/?q={
"filters": [
{
"col": "owners__username",
"opr": "eq",
"value": "bi"
}
]
}
Resulted in Filter column: owners__username not allowed to filter
/api/v1/dashboard/?q={
"filters": [
{
"col": "owners",
"opr": "any",
"value": {
"col": "username",
"opr": "eq",
"value": "bi"
}
}
]
}
Result: Not a valid rison schema
/api/v1/dashboard/?q={
"filters": [
{
"col": "owners",
"opr": "any",
"value": "ADMIN0"
}
]
}
Which gives me all results
What am I missing?
Try this:
/api/v1/dashboard/?q=(filters:!((col:owners,opr:rel_m_m,value:4)))
So that filter only accepts user id's
You can get a list of supported filters on each resource by:
/api/v1/dashboard/_info?q=(keys:!(filters))

List users as non admin with custom fields

As per the documentation, I should be able to get a list of users with a custom schema as long as the field in the schema has a value of ALL_DOMAIN_USERS in the readAccessType property. That is the exact set up I have in the admin console; Moreover, when I perform a get request to the schema get endpoint for the schema in question, I get confirmation that the schema fields are set to ALL_DOMAIN_USERS in the readAccessType property.
The problem is when I perform a users list request, I don't get the custom schema in the response. The request is the following:
GET /admin/directory/v1/users?customer=my_customer&projection=full&query=franc&viewType=domain_public
HTTP/1.1
Host: www.googleapis.com
Content-length: 0
Authorization: Bearer fakeTokena0AfH6SMD6jF2DwJbgiDZ
The response I get back is the following:
{
"nextPageToken": "tokenData",
"kind": "admin#directory#users",
"etag": "etagData",
"users": [
{
"externalIds": [
{
"type": "organization",
"value": "value"
}
],
"organizations": [
{
"department": "department",
"customType": "",
"name": "Name",
"title": "Title"
}
],
"kind": "admin#directory#user",
"name": {
"fullName": "Full Name",
"givenName": "Full",
"familyName": "Name"
},
"phones": [
{
"type": "work",
"value": "(999)999-9999"
}
],
"thumbnailPhotoUrl": "https://photolinkurl",
"primaryEmail": "user#domain.com",
"relations": [
{
"type": "manager",
"value": "user#domain.com"
}
],
"emails": [
{
"primary": true,
"address": "user#domain.com"
}
],
"etag": "etagData",
"thumbnailPhotoEtag": "photoEtagData",
"id": "xxxxxxxxxxxxxxxxxx",
"addresses": [
{
"locality": "Locality",
"region": "XX",
"formatted": "999 Some St Some State 99999",
"primary": true,
"streetAddress": "999 Some St",
"postalCode": "99999",
"type": "work"
}
]
}
]
}
However, if I perform the same request with a super admin user, I get an extra property in the response:
"customSchemas": {
"Dir": {
"fieldOne": false,
"fieldTwo": "value",
"fieldThree": value
}
}
My understanding is that I should get the custom schema with a non admin user as long as the custom schema fields are set to be visible by all domain users. This is not happening. I opened a support ticket with G Suite but the guy that provided "support", send me in this direction. I believe this is a bug or maybe I overlooked something.
I contacted G Suite support and in fact, this issue is a domain specific problem.
It took several weeks for the issue to be addressed by the support engineers at Google but it was finally resolved. The behaviour is the intended one now.

Setting Schema as a run time argument in Datafusion wrangler is not working

We have a requirement to pass on Output Schema of the wrangler as a run time arguments
Below are the formats we tried but nothing seems to work, can any one guide us on how to provide schema as a run time argument through UI or Rest API Call
[
{
"name": "etlSchemaBody",
"schema": {
"type": "record",
"name": "etlSchemaBody",
"fields": [
{
"name": "body_1",
"type": [
"string",
"null"
]
},
{
"name": "body_2",
"type": [
"string",
"null"
]
},
{
"name": "body_3",
"type": [
"string",
"null"
]
},
{
"name": "body_4",
"type": [
"string",
"null"
]
},
{
"name": "body_5",
"type": [
"string",
"null"
]
}
]
}
}
]
"{\"type\":\"record\",\"name\":\"etlSchemaBody\",\"fields\":[{\"name\":\"body_1\",\"type\":[\"string\",\"null\"]},{\"name\":\"body_2\",\"type\":[\"string\",\"null\"]},{\"name\":\"body_3\",\"type\":[\"string\",\"null\"]},{\"name\":\"body_4\",\"type\":[\"string\",\"null\"]},{\"name\":\"body_5\",\"type\":[\"string\",\"null\"]}]}"
Instead of
"{\"type\":\"record\",\"name\":\"etlSchemaBody\",\"fields\":[{\"name\":\"body_1\",\"type\":[\"string\",\"null\"]},{\"name\":\"body_2\",\"type\":[\"string\",\"null\"]},{\"name\":\"body_3\",\"type\":[\"string\",\"null\"]},{\"name\":\"body_4\",\"type\":[\"string\",\"null\"]},{\"name\":\"body_5\",\"type\":[\"string\",\"null\"]}]}"
use
{"type":"record","name":"etlSchemaBody","fields":[{"name":"body_1","type":["string","null"]},{"name":"body_2","type":["string","null"]},{"name":"body_3","type":["string","null"]},{"name":"body_4","type":["string","null"]},{"name":"body_5","type":["string","null"]}]}
as the value for your schema macro.
My guess is that your pipeline run failed with malformed JSON error.
If this does not work, please post logs from the pipeline run.

Passing the value of the select list, to the callback url body on office365 connector card? (payload format)

I'm trying to develop a connector.
I have created the card and the webhook and entered a callback URL to my node.js server for httpost action. I can't get the value of the select list to pass to my server when I click send.
I tried including a body string at the card but then I get
SyntaxError: Unexpected token # in JSON at position 0.
When I send without a body it communicates with my server but I cant get the values. I log the request and there are nowhere.
Below is the a section of the code sample of one office365 connector cards for outlook. It is written in the card reference that the httppost action can contain a body. So i assume this body will be sen to my server with the valu ethat i define. But when i include the body i get the above error and the action doesn't complete as it does without a body.
{
"#type": "ActionCard",
"name": "Move",
"inputs": [
{
"#type": "MultichoiceInput",
"id": "move",
"title": "Pick a list",
"choices": [
{ "display": "List 1", "value": 500 },
{ "display": "List 2", "value": 600 }
]
}
],
"actions": [
{
"#type": "HttpPOST",
"name": "Save",
"target": "https://aptdevserver.westeurope.cloudapp.azure.com/chat/messages/create",
"body": "value",
"bodyContentType": "application/json"
}
]
}
You're not telling Outlook which value you want to send. You need to tell it that you want to do a string replacement, otherwise you are litterally sending the string value in the body of your POST:
"body": "{ \"move\": \"{{move.value}}\" }"
Using your complete example:
{
"#type": "ActionCard",
"name": "Move",
"inputs": [
{
"#type": "MultichoiceInput",
"id": "move",
"title": "Pick a list",
"choices": [
{ "display": "List 1", "value": 500 },
{ "display": "List 2", "value": 600 }
]
}
],
"actions": [
{
"#type": "HttpPOST",
"name": "Save",
"target":
"https://aptdevserver.westeurope.cloudapp.azure.com/chat/messages/create",
"body": "{ \"move\": \"{{move.value}}\" }",
"bodyContentType": "application/json"
}
]
}