How to add a simple flow rule via OpenDaylight DLUX using the /operations/sal-flow:add-flow api - lithium

I am trying to add a simple flow rule via Lithium's DLUX using the /operations/sal-flow:add-flow api call but getting nothing but errors, please can someone help?
Even a preview of a sample flow someone has added would be really helpful?
My current input as displayed in the preview frame is:
http://localhost:8181/restconf/operations/sal-flow:add-flow
{
"add-flow": {
"input": {
"match": {
"ethernet-match": {
"ethernet-type": {
"type": "2048"
}
},
"ipv4-source": "10.0.0.1/32"
},
"instructions": {
"instruction": [
{
"order": "0",
"apply-actions": {
"action": [
{
"drop-action": {},
"order": "0"
}
]
}
}
]
},
"flow-name": "test",
"table_id": "0"
}
}
}
The current error is:
"Server Error : The server encountered an unexpected condition which prevented it from fulfilling the request. - : The operation encountered an unexpected error while"
The same request in Postman gives the error:
{
"errors": {
"error": [
{
"error-type": "protocol",
"error-tag": "malformed-message",
"error-message": "Error parsing input: Schema node with name add-flow wasn't found under (urn:opendaylight:flow:service?revision=2013-08-19)add-flow."
}
]
}
}
I have seen examples using xml but nothing that seems to work. I am able to view the network topology via dlux so I presume I am connected to everything ok.
Many thanks in advance.

Remove the add-flow and the corresponding brackets from the input data. Use things like
{
input: {...},
output: {...}
}

I am having the same problem using DLUX. Anyway I managed to find a solution using XML POST requests from this link https://wiki.opendaylight.org/view/OpenDaylight_OpenFlow_Plugin:End_to_End_Flows. You can use POSTMAN application on Chrome to send requests. The body of the request should be something like:
POST http://localhost:8080/restconf/operations/sal-flow:add-flow
Add authentication header too.
Content-type: application/xml
Accept: application/xml
Body:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<input xmlns="urn:opendaylight:flow:service">
<barrier>false</barrier>
<node xmlns:inv="urn:opendaylight:inventory">/inv:nodes/inv:node[inv:id="openflow:1"]</node>
<cookie>55</cookie>
<flags>SEND_FLOW_REM</flags>
<hard-timeout>0</hard-timeout>
<idle-timeout>0</idle-timeout>
<installHw>false</installHw>
<match>
<ethernet-match>
<ethernet-type>
<type>2048</type>
</ethernet-type>
</ethernet-match>
<ipv4-destination>10.0.10.2/32</ipv4-destination>
</match>
<instructions>
<instruction>
<order>0</order>
<apply-actions>
<action>
<output-action>
<output-node-connector>1</output-node-connector>
</output-action>
<order>0</order>
</action>
</apply-actions>
</instruction>
</instructions>
<priority>0</priority>
<strict>false</strict>
<table_id>0</table_id>
</input>

Related

mail.send is not accepting HTML/ CSS code

I have copied the (HTML) source code from a received email just to have the template/format of that email, and this is the error message that I am receiveing when running the API:
Internal : Unexpected error Error during Web API HTTP Request
HTTP Status Code: 400
HTTP Response Content: {
"error": {
"code": "BadRequest",
"message": "Unable to read JSON request payload. Please ensure Content-Type header is set and payload is of valid JSON format.",
"innerError": {
"date": "2020-12-02T17:01:05",
"request-id": "3ab50fc1-0c13-4536-96db-bf6b9b7a736d",
"client-request-id": "3ab50fc1-0c13-4536-96db-bf6b9b7a736d"
}
}
}
I have tested basic commands using HTML such as making text bold and line breaks which work, but anything more complex and I will receive an error.
Update**
Thank you for your response guys, the call that I'm using looks like this:
{
"message": {
"subject": "[Subject]",
"body": {
"contentType": "HTML",
"content": "[Email Body Content]"
},
"toRecipients": [
{
"emailAddress": {
"address": "[Email Address]"
}
}
],
"internetMessageHeaders":[
{
"name":"x-custom-header-group-name",
"value":"Nevada"
},
{
"name":"x-custom-header-group-id",
"value":"NV001"
}
]
}
}
**Another update ** Upon changing the content type to text/html is recieved this error:
Internal : Unexpected error Error during Web API HTTP Request
HTTP Status Code: 415
HTTP Response Content: {"error":{"code":"RequestBodyRead","message":"A supported MIME type could not be found that matches the content type of the response. None of the supported type(s) 'Microsoft.OData.ODataMediaType, Microsoft.OData.ODataMediaTyp...' matches the content type 'text/plain; charset=utf-8'."}}
note i also have tried text/plain as the content type.
Thank you
Ok, I tried the above payload (just updated the email address) and tested with Microsoft Graph Explorer. It works for me :)
Here's the payload:
{"message":{"subject":"[Subject]","body":{"contentType":"HTML","content":"[Email Body Content]"},"toRecipients":[{"emailAddress":{"address":"test#domain.onmicrosoft.com"}}],"internetMessageHeaders":[{"name":"x-custom-header-group-name","value":"Nevada"},{"name":"x-custom-header-group-id","value":"NV001"}]}}
Here's the snapshot:

Invalid variant ID while creating checkout for Shopify

I am trying to create checkout url using Admin API with following params.
URL: https://shopy-test11.myshopify.com/admin/api/2020-10/checkouts.json
{
"checkout": {
"line_items": [
{
"variant_id": 37033347711169,"quantity": 2
}
]
}
}
Unfortunately its returning below error which is not properly documented anywhere that I could find.
{
"errors": {
"line_items": {
"0": {
"variant_id": [
{
"code": "invalid",
"message": "is invalid",
"options": {}
}
]
}
}
}
}
I also tried Shopify-api ruby gem and got same error. There are some similar issue online, but none answers why that issue is occurring and how to fix it. This is new app under development which will create custom checkout. There's only one sales channel which is "Online Store" and is enabled for all products. Any ideas how to fix this issue? Any help is appreciated.
You seem to be mixing up concepts here. The checkout API is only associated with the Storefront API, and has nothing to do with the Admin API.
So this URL: /admin/api/2020-10/checkouts.json seems to be impossible. There is no endpoint in the admin API for checkouts, whereas, Storefront API which does have checkouts, might be your proper URL. So try that:
/api/2020-10/checkouts.json
And if you have the correct token in your header, it will likely work.

Try to patch TEXT in a Classroom announcements over API

I'm not able to change 'text' in an announcements using Google-Classroom API.
When I try to use the PATCH method I have the following error:
{
"error": {
"code": 400,
"message": "updateMask: Non-supported update mask fields specified",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"field": "updateMask",
"description": "Non-supported update mask fields specified"
}
]
}
]
}
}
request and updateMask
I send a updateMask 'text' and a text in request body.
When I try with the updateMask 'state,scheduledTime' I get a successful.
Has anyone ever had this error?
References:
https://developers.google.com/classroom/reference/rest/v1/courses.announcements/patch
I had the same issue. Despite what the documentation seems to indicate (that updateMask can be text), I couldn't get it to work.
I got around it by creating a new post with the information from the announcement, and deleting the old announcement.
This is probably what you did too.

How to post event with metadata to stream through HTTP API

I'm using EventStore and want to post a message (event) to it. I use the HTTP API for testing purposes. I've managed to post the event itself, with an event type specified, but I can't figure out how to specify metadata for my event. (and I must provide this metadata because my consuming application on the other side expects it).
This is what my HTTP request looks like:
Content-Type: application/json
ES-EventType: My.own.event.type
POST http://10.0.75.2:2113/web/index.html#/streams/foobar
{
"props": "andvalues"
}
Do I specify metadata in the body in through headers? I can't find much docs about this, only the official that doesn't mention it.
The documentation mentions the full schema for an event being written. It looks like this:
[
{
"eventId" : "string",
"eventType" : "string",
"data" : "object",
"metadata" : "object"
}
]
For example:
[
{
"eventId": "fbf4a1a1-b4a3-4dfe-a01f-ec52c34e16e4",
"eventType": "event-type",
"data": { "a": "1" },
"metadata": { "b": "2" }
}
]
Note that it's an array, and that you must pass content-type as application/vnd.eventstore.events+json
Check this page, scroll to Event Store Events Media Type.

Shopify API, unable to create order

I created private application on my test shop and I am trying to create simple order via the Shopify API following the instructions found here:
http://docs.shopify.com/api/order#create
I am using the last example, and sending POST request to admin/orders.json with this in the body of the request:
{
"order": {
"line_items": [
{
"quantity": 1,
"variant_id": 500775053
}
]
}
}
500775053 is a valid variant id.
The response I'm getting is:
{
"errors": {
"line_items": [
"must have at least one line item"
]
}
}
I don't understand what am I doing wrong? Is there some special parameter that I should pass along the request? Some special header?
Thank you for your help!
Try adding these custom headers:
Content-Type: application/json
Accept: application/json