I need to edit the request header using declarativeNetRequest:
{
"id": 1,
"priority": 1,
"action": {
"type": "modifyHeaders",
"requestHeaders": [{"header": "someHeader", "operation": "append", "value": "newValue"}]
},
"condition": {
"urlFilter": "*",
"resourceTypes": ["main_frame", "xmlhttprequest"]
}
}
Expected Result:
The header should be modified
{
name: "someHeader"
value: "oldValue; newValue"
}
Actual Result:
dynamic rules:
Unchecked runtime.lastError: Rule with id 1 must not specify a request header to be appended.
general rules:
Failed to load extension
File D:\extensions\test-extensions\web\app\chrome
Error rules.json: Rule with id 1 must not specify a request header to be appended.
Could not load manifest.
Related
The project has two authorization systems, basic auth and bearer. I need for each request after clicking on the "try it out" and "execute" buttons to attach to the request the Authorization headers, in which there will be a Basic line and a jwt header, in which there will be a bearer token. The problem is that I can attach these headers individually, but not together. There is a feeling that both authorizations want to write to the Authorization header and one of them overwrites the other, even though I explicitly indicated the header names in the schema.
My schemas:
{
"securitySchemes": {
"Bearer": {
"in": "header",
"name": "jwt",
"type": "http",
"scheme": "bearer"
},
"basicAuth": {
"type": "http",
"scheme": "basic"
}
}
}
and how I use it:
{
"/channel/base-list": {
"get": {
"tags": [
"CMS Channel"
],
"security": [
{
"Bearer": [],
"basicAuth": []
}
],
"summary": "Get _id and title of all channels",
"produces": [
"application/json"
],
"parameters": [
{
"in": "query",
"name": "count",
"required": false,
"schema": {
"type": "Integer"
},
"default": 25,
"example": 10
},
{
"in": "query",
"name": "search",
"required": false,
"schema": {
"type": "String"
},
"description": "Channel name"
}
],
"responses": {
"200": {
"description": "A list of channels",
"content": {
"application/json": {
"schema": {
"$ref": "#/definitions/get-channel-base-list"
}
}
}
}
}
}
}
}
I use swagger-ui-express for node.JS and OpenAPI 3.0
A request can contain only one Authorization header, and the Authorization header can only contain a single set of credentials (i.e. either Basic or Bearer, but not both). Your use case is not supported by the HTTP protocol.
In Manifest V3 Chrome's team introduced declarativeNetRequest. We can't seem to make sure those rules are applied only to sites of a certain domain:
[
{
"id": 1,
"priority": 1,
"action": {
"type": "block"
},
"condition": {
"urlFilter": "main.js",
"resourceTypes": ["script"]
}
}
]
We defined, those rules are fired in every webpage you visit. Can we filter the rules by this host of rule and not by the destination of the script? We couldn't find indication for it in the docs or the examples.
Needless to say any off-docs improvisation in the manifest.json failed to leave a mark. For instance:
{
...
"declarative_net_request": {
"matches": ["https://SUB_DOMAIN_NAME.domain.com/*"], <====== this
"rule_resources": [
{
"id": "ruleset_1",
"enabled": true,
"path": "rules.json"
}
]
}
}
References to internal sections in swagger.json work correctly, but attempting to reference a JSON file in the same directory seems to be ignored. I have some large example data files so would like to reference them instead of including them in the swagger.json file.
How do I get swagger to dereference the $ref tags for external files in the ./static/ directory (this is the same location as the swagger.json file)? Is there a swagger log file that shows what/how it loads files?
Things that work:
http://localhost:5002/swagger
http://localhost:5002/static/swagger.json
http://localhost:5002/static/components.json
So this proves the web server can find the static/components.json file.
Part of swagger.json:
"components": {
"schemas": {
"id": {
"properties": {
"id": {
"type": "number",
"format": "int64"
}
}
},
"componentsPost": {
"type": "object",
"properties": {
"id": {
"$ref": "#/components/schemas/id" <-- THIS WORKS
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"component_type_id": {
"$ref": "#/components/schemas/id" <-- THIS WORKS
},
"system_type_id": {
"$ref": "#/components/schemas/id" <-- THIS WORKS
},
"parent_id": {
"$ref": "#/components/schemas/id"
}
},
"example": {
"$ref": "components.json" <-- THIS DOES *NOT* WORK
}
},
Note: components.json is different than the #components/schema/id
reference, which is in the same file as shown above.
Beginning of components.json data file:
{
"components": [
{
"id": 99999,
"name": "root",
"description": "Root Component",
"component_type_id": 1,
"system_type_id": 1
},
{
"id": 1,
"name": "lan1",
"description": "LAN",
"component_type_id": 1,
"system_type_id": 4,
"parent_id": 99999
},
The swagger.json file gets loaded but components.json does not:
[06/Jan/2021 12:32:53] "GET /static/swagger.json HTTP/1.1" 200 -
The swagger web site shows the $ref, not the expected components.json:
Alternate code I have tried:
"example": {
"components": {
"$ref": "components.json"
}
}
"example": {
"$ref": "/static/components.json"
}
"example": {
"$ref": "./static/components.json"
}
"example": {
"$ref": "static/components.json"
}
[
{
"id": 1,
"priority": 2,
"action": {
"type": "redirect",
"redirect": { "regexSubstitution": "http://localhost:28438/check-url?url=\\0" }
},
"condition": {
"regexFilter": "^(https?\\://)?[^\\:]+$",
"resourceTypes": [ "main_frame" ],
"excludedDomains":["localhost"]
}
},
{
"id": 2,
"priority": 1,
"action": {
"type": "redirect",
"redirect": {
"regexSubstitution": "\\1"
}
},
"condition": {
"regexFilter": "^(?:http\\://)?localhost.+pass\\?url=(.+)$",
"resourceTypes": [ "main_frame" ]
}
}
]
According to the above rule #1, every request originating from localhost should be ignored and the rest should be redirected to the local server.
I have added the rule #2 for a possibly broader view of the case; it's really redundant to post it here.
My expectation, however, is not satisfied and the request gets intercepted, resulting in an infinite loop:
In this case, I try to open the msn website and it gets intercepted by the first rule (the second rule acts OK).
I'm trying to insert a stock item into Acumatica using the API, but I'm getting a 400 error - Bad Request. I'm using HttpClient to login, retrieve a stock item, and send the insert request. All is working except the insert request. I have tried the following url (including expand parameter):
http://localhost/AcumaticaERP/entity/Default/6.00.001/StockItem?$expand=Attributes,CrossReferences,UOMConversions,VendorDetails,WarehouseDetails
... and also the following url (without expand parameter)
http://localhost/AcumaticaERP/entity/Default/6.00.001/StockItem
I'm calling via HttpClient PutAsync, passing in the URLs mentioned above, and the data is JSON from a stock item retrieved with the API, and which doesn't exist in the current db.
client.PutAsync(insertUrl, new StringContent(data, Encoding.UTF8, "application/json")).Result;
Any ideas what I'm missing?
NEW DETAILS:
After further debugging and testing with Postman, the error from the PUT seems to be "Error reading JObject from JsonReader. Current JsonReader item is not an object: StartArray. Path '', line 1, position 1." The JSON was taken directly from a GET though, so I'm not sure what the problem could be. Below is the JSON returning an error from the PUT.
[
{
"id": "cc27ce56-6302-4f1b-97aa-49cca3ed32ea",
"rowNumber": 1,
"note": "",
"Attributes": [],
"BaseUOM": {
"value": "EA"
},
"CrossReferences": [],
"DefaultIssueLocationID": {
"value": "R1S1"
},
"DefaultReceiptLocationID": {
"value": "RECEIVING"
},
"DefaultWarehouseID": {
"value": "WHOLESALE"
},
"Description": {
"value": "tonyitem2"
},
"ImageUrl": {},
"InventoryID": {
"value": "TONYITEM2"
},
"IsAKit": {
"value": false
},
"ItemClass": {
"value": "CONSUMER 300TOYS"
},
"ItemStatus": {
"value": "Active"
},
"ItemType": {
"value": "Finished Good"
},
"LastModified": {
"value": "2018-08-03T12:09:19.907-04:00"
},
"LotSerialClass": {
"value": "NOTTRACKED"
},
"PurchaseUOM": {
"value": "EA"
},
"SalesUOM": {
"value": "EA"
},
"UOMConversions": [],
"VendorDetails": [],
"Volume": {
"value": 0
},
"WarehouseDetails": [
{
"id": "3ca5ea4c-c651-498e-8e6c-49119481982c",
"rowNumber": 1,
"note": "",
"DefaultIssueLocationID": {
"value": "R1S1"
},
"DefaultReceiptLocationID": {
"value": "RECEIVING"
},
"IsDefault": {
"value": true
},
"QtyOnHand": {
"value": 0
},
"WarehouseID": {
"value": "WHOLESALE"
},
"custom": {},
"files": []
}
],
"Weight": {
"value": 0
},
"custom": {},
"files": []
}
]
I also tried removing the brackets surrounding the JSON, and then the error is:
"No entity satisfies the condition.". Could the issue be that the ids have GUIDs, but I'm trying to do an insert? How do you indicate that the PUT is supposed to be inserting?
I finally got the PUT to insert. What finally worked was removing the wrapping braces "[" and "]" around the entire JSON; plus removing all "id", "rowNumber", "custom", and "files" fields, and all empty collections (e.g. Attributes, CrossReferences) in my JSON. I'm not sure which of these being removed resolved it and allowed me to insert, but it finally worked.
It's real unfortunate that the JSON you retrieve via GET can't be inserted via PUT without stripping all of this out first though. What a pain.