Azure DevOps API release definition error - api

I am creating azure-devops release pipeline with API, but getting error. I have validated the json as well and is correct from https://jsonlint.com/ Any help would be really appreciated
I have followed this issue as well and retention policy is correctly passed
Azure DevOps API release definition
error: "message": "VS402982: A retention policy is not set for the stage β€˜Test-New-2’. Retention policies at the release pipeline level are deprecated. Use a retention policy at the stage level
POST https://vsrm.dev.azure.com/{{organization}}/{{project}}/_apis/release/definitions?api-version=6.0
json body:
"retentionPolicy": {
"daysToKeep": 30,
"releasesToKeep": 3,
"retainBuild": true
},

Yes, it should be the syntax issue, to create a release definition, you could refer to this sample.
Reruest URL:
POST https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/definitions?api-version=6.0
Request Body:
{
"source": "undefined",
"revision": 1,
"description": null,
"createdBy": null,
"createdOn": "0001-01-01T00:00:00",
"modifiedBy": null,
"modifiedOn": "0001-01-01T00:00:00",
"isDeleted": false,
"variables": {},
"variableGroups": [],
"environments": [
{
"id": 0,
"name": "PROD",
"variables": {},
"variableGroups": [],
"preDeployApprovals": {
"approvals": [
{
"rank": 1,
"isAutomated": false,
"isNotificationOn": false,
"approver": {
"displayName": null,
"id": "aeb95c63-4fac-4948-84ce-711b0a9dda97"
},
"id": 0
}
]
},
"postDeployApprovals": {
"approvals": [
{
"rank": 1,
"isAutomated": true,
"isNotificationOn": false,
"id": 0
}
]
},
"deployPhases": [
{
"deploymentInput": {
"parallelExecution": {
"parallelExecutionType": "none"
},
"skipArtifactsDownload": false,
"artifactsDownloadInput": {},
"queueId": 15,
"demands": [],
"enableAccessToken": false,
"timeoutInMinutes": 0,
"jobCancelTimeoutInMinutes": 1,
"condition": "succeeded()",
"overrideInputs": {}
},
"rank": 1,
"phaseType": "agentBasedDeployment",
"name": "Run on agent",
"workflowTasks": []
}
],
"environmentOptions": {
"emailNotificationType": "OnlyOnFailure",
"emailRecipients": "release.environment.owner;release.creator",
"skipArtifactsDownload": false,
"timeoutInMinutes": 0,
"enableAccessToken": false,
"publishDeploymentStatus": false,
"badgeEnabled": false,
"autoLinkWorkItems": false,
"pullRequestDeploymentEnabled": false
},
"demands": [],
"conditions": [],
"executionPolicy": {
"concurrencyCount": 0,
"queueDepthCount": 0
},
"schedules": [],
"retentionPolicy": {
"daysToKeep": 30,
"releasesToKeep": 3,
"retainBuild": true
},
"properties": {},
"preDeploymentGates": {
"id": 0,
"gatesOptions": null,
"gates": []
},
"postDeploymentGates": {
"id": 0,
"gatesOptions": null,
"gates": []
},
"environmentTriggers": []
}
],
"artifacts": [],
"triggers": [],
"releaseNameFormat": null,
"tags": [],
"properties": {},
"id": 0,
"name": "Fabrikam-web",
"projectReference": null,
"_links": {}
}
I test it on my side, it works for me.

Related

Product Visibility

Issue
When logged in as a buyer, I am unable to see a product I should have access to. Issuing this request, /v1/me/products while passing a token for user buyer01, I see this response:
{
"Meta": {
"Facets": [],
"Page": 1,
"PageSize": 20,
"TotalCount": 0,
"TotalPages": 0,
"ItemRange": [
1,
0
],
"NextPageKey": null
},
"Items": []
}
I expect to see the product SHIRT listed in the Items array element.
Visibility rules
I've worked through the Visibility Rules Checklist and I believe all conditions have been met:
Product.Active = true
Catalog exists where:
Catalog.Active = true
Buyer is assigned via CatalogAssignment
Product is assigned via ProductCatalogAssignment
One of the following is true:
CatalogAssignment.ViewAllProducts = true
Product is active
{{baseUrl}}/v1/products returns this response:
{
"Meta": {
"Facets": [],
"Page": 1,
"PageSize": 20,
"TotalCount": 1,
"TotalPages": 1,
"ItemRange": [
1,
1
],
"NextPageKey": null
},
"Items": [
{
"OwnerID": "xxxxxxxxxxxxxxxx",
"DefaultPriceScheduleID": "SHIRT_PRICE",
"AutoForward": false,
"ID": "SHIRT",
"Name": "Cotton T-Shirt",
"Description": "A plain white, cotton shirt for everyday use.",
"QuantityMultiplier": 1,
"ShipWeight": null,
"ShipHeight": null,
"ShipWidth": null,
"ShipLength": null,
"Active": true,
"SpecCount": 0,
"VariantCount": 0,
"ShipFromAddressID": null,
"Inventory": null,
"DefaultSupplierID": null,
"AllSuppliersCanSell": false,
"Returnable": false,
"xp": null
}
]
}
Catalog is active
{{baseUrl}}/v1/catalogs returns
{
"Meta": {
"Page": 1,
"PageSize": 20,
"TotalCount": 1,
"TotalPages": 1,
"ItemRange": [
1,
1
],
"NextPageKey": null
},
"Items": [
{
"ID": "BUYER_ORGANIZATION",
"OwnerID": "xxxxxxxxxxxxxxxx",
"Name": "Example Buyer",
"Description": "Default catalog for Example Buyer",
"Active": true,
"CategoryCount": 0,
"xp": null
}
]
}
Buyer is assigned
Buyer user in organization
{{baseUrl}}/v1/me (with buyer01 cookie) returns:
{
"Buyer": {
"ID": "BUYER_ORGANIZATION",
"DefaultCatalogID": "BUYER_ORGANIZATION"
},
"Supplier": null,
"Seller": {
"ID": "xxxxxxxxxxxxxxxx"
},
"ID": "BUYER_USER",
"CompanyID": "BUYER_ORGANIZATION",
"Username": "buyer01",
"Password": null,
"FirstName": "Buyer",
"LastName": "User",
"Email": "buyer#email.com",
"Phone": null,
"TermsAccepted": null,
"Active": true,
"xp": null,
"AvailableRoles": [
"MeAdmin",
"PasswordReset",
"Shopper"
],
"Locale": null,
"DateCreated": "2022-12-21T00:43:53.507+00:00",
"PasswordLastSetDate": "2022-12-21T00:43:53.543+00:00"
}
Buyer organization is assigned catalog
{{baseUrl}}/v1/catalogs/assignments returns
{
"Meta": {
"Page": 1,
"PageSize": 20,
"TotalCount": 1,
"TotalPages": 1,
"ItemRange": [
1,
1
],
"NextPageKey": null
},
"Items": [
{
"CatalogID": "BUYER_ORGANIZATION",
"BuyerID": "BUYER_ORGANIZATION",
"ViewAllCategories": true,
"ViewAllProducts": true
}
]
}
Product is assigned
This may be the issue. When I make the documented assignment:
{{baseUrl}}/v1/catalogs/productassignments
{
"CatalogID": "BUYER_ORGANIZATION",
"ProductID": "SHIRT"
}
I receive a 200 response that does not show any assignment has occurred:
{
"Meta": {
"Page": 1,
"PageSize": 20,
"TotalCount": 0,
"TotalPages": 0,
"ItemRange": [
1,
0
],
"NextPageKey": null
},
"Items": []
}
Note that the above request, as all other steps, is taken from the Getting Started walkthrough. This step is provided under Making Your Product Visible.
This is confirmed by this request:
{{baseUrl}}/v1/products/assignments, which returns no products.
{
"Meta": {
"Page": 1,
"PageSize": 20,
"TotalCount": 0,
"TotalPages": 0,
"ItemRange": [
1,
0
],
"NextPageKey": null
},
"Items": []
}
View all products is true
{{baseUrl}}/v1/catalogs/assignments returns
{
"Meta": {
"Page": 1,
"PageSize": 20,
"TotalCount": 1,
"TotalPages": 1,
"ItemRange": [
1,
1
],
"NextPageKey": null
},
"Items": [
{
"CatalogID": "BUYER_ORGANIZATION",
"BuyerID": "BUYER_ORGANIZATION",
"ViewAllCategories": true,
"ViewAllProducts": true
}
]
}
The issue was that I was making a GET request instead of a POST when doing this:
{{baseUrl}}/v1/catalogs/productassignments
When issuing a POST, the service returns a 204 No Content.
It is worth noting that the tutorial is a bit out of date--the current Product API documentation omits the above call, and instead has /products/assignments here. This method will return a 405 Method Not Allowed an error if doing a GET, which makes this issue easier to identify.
Now when I view /me/products as buyer01 I see this:
{
"Meta": {
"Facets": [],
"Page": 1,
"PageSize": 20,
"TotalCount": 1,
"TotalPages": 1,
"ItemRange": [
1,
1
],
"NextPageKey": null
},
"Items": [
{
"PriceSchedule": {
"OwnerID": "xxxxxxxxxxxxxxxx",
"ID": "SHIRT_PRICE",
"Name": "Cotton T-Shirt Price",
"ApplyTax": false,
"ApplyShipping": false,
"MinQuantity": 1,
"MaxQuantity": null,
"UseCumulativeQuantity": false,
"RestrictedQuantity": false,
"PriceBreaks": [
{
"Quantity": 1,
"Price": 10.0,
"SalePrice": null
}
],
"Currency": null,
"SaleStart": null,
"SaleEnd": null,
"IsOnSale": false,
"xp": null
},
"ID": "SHIRT",
"Name": "Cotton T-Shirt",
"Description": "A plain white, cotton shirt for everyday use.",
"QuantityMultiplier": 1,
"ShipWeight": null,
"ShipHeight": null,
"ShipWidth": null,
"ShipLength": null,
"Active": true,
"SpecCount": 0,
"VariantCount": 0,
"ShipFromAddressID": null,
"Inventory": null,
"DefaultSupplierID": null,
"AllSuppliersCanSell": false,
"Returnable": false,
"xp": null
}
]
}

How to create complex-rules for modifier of product in bigcommerce

I am new in bigcommerce and type to added complex-rules for Modifier of product. below provide the URL of API URL and JSON.
every time give error "The rule must contain multiple modifier conditions with unique modifier ids or a variant condition and modifier condition"
https://api.bigcommerce.com/stores/{$$.env.store_hash}/v3/catalog/products/{product_id}/complex-rules
Please help where I wrong in send Complex Rule request JSON.
Modifier:
{
"data": {
"config": [],
"display_name": "Donation",
"id": 188,
"name": "Donation1645178599-166",
"option_values": [
{
"adjusters": {
"image_url": "",
"price": null,
"purchasing_disabled": {
"message": "",
"status": false
},
"weight": null
},
"id": 352,
"is_default": true,
"label": "$5 Donation",
"option_id": 188,
"sort_order": 0,
"value_data": null
},
{
"adjusters": {
"image_url": "",
"price": null,
"purchasing_disabled": {
"message": "",
"status": false
},
"weight": null
},
"id": 353,
"is_default": false,
"label": "$10 Donation",
"option_id": 188,
"sort_order": 0,
"value_data": null
}
],
"product_id": 166,
"required": false,
"sort_order": 0,
"type": "dropdown"
},
"meta": {}
}
Complex Rule request JSON:
{
"product_id": 166,
"sort_order": 0,
"enabled": true,
"stop": false,
"purchasing_disabled": false,
"purchasing_hidden": false,
"price_adjuster": {
"adjuster": "relative",
"adjuster_value": 6
},
"weight_adjuster": {
"adjuster": "relative",
"adjuster_value": 6
},
"conditions": [
{
"id": 5,
"rule_id": 5,
"modifier_id": 189,
"modifier_value_id": 352
}
]
}
Error output:
{
"status": 422,
"title": "The rule must contain multiple modifier conditions with unique modifier ids or a variant condition and modifier condition",
"type": "https://developer.bigcommerce.com/api-docs/getting-started/api-status-codes"
}

Weird behavior in vue/vuetify attribute binding with template literals

I tried to feet the v-treeview component in vuetify with an object, wrapped in an array, as an template literal.
<template lang="pug">
v-container.media-lib-container
v-treeview(:items="[media]" dense)
v-btn(#click="test") test
</template>
The page is loading normal but when I try to open the tree view, I get an type error in vuetify.js.
TypeError: Cannot set property 'vnode' of undefined
at VueComponent.register (vuetify.js?ce5b:30786)
Weirdly when I compute the data, and return it as an template literal it works fine.
computed: {
mediaArr() {
return [this.media];
},
},
Does anyone know if this is a bug or if I miss something? and if this is caused by vue or by vuetify?
I think I know at least where my problem hides.
I get my object from npm directory-tree module and than add an id property to every child for the v-treeview. Also it stopped working again(maybe never has).
The original json:
{
"path": "../uploads",
"name": "uploads",
"children": [
{ "path": "../uploads/parsed", "name": "parsed", "children": [], "size": 0, "type": "directory" },
{
"path": "../uploads/test",
"name": "test",
"children": [
{ "path": "../uploads/test/test2", "name": "test2", "children": [], "size": 0, "type": "directory" }
],
"size": 0,
"type": "directory"
},
{
"path": "../uploads/uploads",
"name": "uploads",
"children": [
{
"path": "../uploads/uploads/public",
"name": "public",
"children": [
{
"path": "../uploads/uploads/public/projectA",
"name": "projectA",
"children": [],
"size": 0,
"type": "directory"
},
{
"path": "../uploads/uploads/public/projectB",
"name": "projectB",
"children": [],
"size": 0,
"type": "directory"
}
],
"size": 0,
"type": "directory"
}
],
"size": 0,
"type": "directory"
}
],
"size": 0,
"type": "directory"
}
The parsed object with the added id:
path: "../uploads",
name: "uploads",
children: [
{
path: "../uploads/parsed",
name: "parsed",
children: [],
size: 0,
type: "directory",
id: 1,
},
{
path: "../uploads/test",
name: "test",
children: [
{
path: "../uploads/test/test2",
name: "test2",
children: [],
size: 0,
type: "directory",
id: 3,
},
],
size: 0,
type: "directory",
id: 2,
},
{
path: "../uploads/uploads",
name: "uploads",
children: [
{
path: "../uploads/uploads/public",
name: "public",
children: [
{
path: "../uploads/uploads/public/projectA",
name: "projectA",
children: [],
size: 0,
type: "directory",
id: 6,
},
{
path: "../uploads/uploads/public/projectB",
name: "projectB",
children: [],
size: 0,
type: "directory",
id: 7,
},
],
size: 0,
type: "directory",
id: 5,
},
],
size: 0,
type: "directory",
id: 4,
},
],
size: 0,
type: "directory",
id: 0,
},
The code in mounted to add id:
mounted() {
let id = 0;
function recur(obj) {
obj.id = id;
++id;
obj.children.map((child) => recur(child));
}
recur(this.media);
},
The thing I don't understand is, that when I console.log(JSON.stringify(this.media) and put it directly in vue data it works. Both as a template literal in the attribute binding and as computed.

Automatic restart of workflows in node-red

I asked this question also in the node-red forum, but there is not much activity (compared to stackoverflow). So I try it here again. The motivation of my question is, that I sometime loose the connection to an OPC-UA-Server that requires restart of the flow to work again. I want to do this automatically in background, because the rare restart of the flow is no big issue - so I can live with it.
There is a thread https://discourse.nodered.org/t/how-to-restart-flows-automatically/12993 that is not really finished or solved.
I implemented the last example, but get error 400, so automatic restart of flow doesn't work. Is there any fool proof description how to do this?
EDIT:
This is the code:
[
{
"id": "3623f8cf.b4d2b8",
"type": "subflow",
"name": "restart flows",
"info": "",
"category": "",
"in": [
{
"x": 40,
"y": 80,
"wires": [
{
"id": "f24fbf79.77a74"
}
]
}
],
"out": [
{
"x": 960,
"y": 80,
"wires": [
{
"id": "cb4d3992.931138",
"port": 0
}
]
}
],
"env": [
{
"name": "user",
"type": "str",
"value": ""
},
{
"name": "password",
"type": "str",
"value": ""
}
],
"color": "#FF8888",
"inputLabels": [
"Injection"
],
"icon": "node-red/alert.svg"
},
{
"id": "f24fbf79.77a74",
"type": "function",
"z": "3623f8cf.b4d2b8",
"name": "Request Token",
"func": "var user = env.get('user');\nvar pass = env.get('password');\n\nif(user === undefined || user === null)\n{\n user = 'adminuser';\n}\nif(pass === undefined || pass === null)\n{\n pass = 'adminpass';\n}\n\nmsg.payload = {\n \"client_id\": \"node-red-editor\",\n \"grant_type\": \"password\",\n \"scope\": \"*\",\n \"username\": user,\n \"password\": pass\n}\nreturn msg;\n\n/*\nmsg.payload = {\n \"client_id\": \"node-red-editor\",\n \"grant_type\": \"password\",\n \"scope\": \"*\",\n \"username\": \"type or username\",\n \"password\": \"type your password\"\n}\nreturn msg;\n*/",
"outputs": 1,
"noerr": 0,
"x": 200,
"y": 80,
"wires": [
[
"3aedf561.e16f4a"
]
]
},
{
"id": "3aedf561.e16f4a",
"type": "http request",
"z": "3623f8cf.b4d2b8",
"name": "Token",
"method": "POST",
"ret": "txt",
"paytoqs": false,
"url": "http://servername:port/auth/token",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"x": 390,
"y": 80,
"wires": [
[
"388fe2f5.639eee"
]
]
},
{
"id": "388fe2f5.639eee",
"type": "function",
"z": "3623f8cf.b4d2b8",
"name": "Confirm token",
"func": "// get the status of the request\nvar status = msg.statusCode;\nvar token = '';\nmsg.headers ={};\n\n//let node = feedback;\n\nswitch(status){\n case 200:\n node.log(\"Secure restart\");\n token = JSON.parse(msg.payload);\n token = 'Bearer '+token.access_token;\n msg.headers = {\n \"Authorization\": token,\n \"Node-RED-Deployment-Type\":\"reload\"\n }\n msg.payload =\"\";\n break;\n case 204:\n node.log(\"Secure without restart\");\n global.set('result','\tSuccess - with no further content');\n break;\n case 400:\n node.warn(\"Bad request\");\n break;\n case 401:\n node.warn(\"Not authorized\");\n break;\n case 403:\n node.warn(\"Forbidden\");\n break;\n case 404:\n node.log(\"Unsecure restart\");\n msg.headers = {\n \"Node-RED-Deployment-Type\":\"reload\"\n }\n break;\n case 409:\n node.warn(\"Version mismatch\");\n break;\n case 500:\n node.error(\"Server Error\");\n break;\n default:\n node.warn(\"Unknown Error\");\n break;\n}\n\nmsg.payload = \"\";\n\nsetTimeout(function() { node.send(msg) }, 10000);\n\nreturn null;",
"outputs": 1,
"noerr": 0,
"x": 580,
"y": 80,
"wires": [
[
"cb4d3992.931138"
]
],
"info": "Restart of Node-Red flows.\nWill check if the action needs security or not.\nNote: if the first 5 attemps return a statuscode 403 'forbidden'\nthen the server will break and only way to recover is then to\nrestart the service"
},
{
"id": "cb4d3992.931138",
"type": "http request",
"z": "3623f8cf.b4d2b8",
"name": "Restart",
"method": "POST",
"ret": "txt",
"paytoqs": false,
"url": "http://servername:port/flows",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"x": 780,
"y": 80,
"wires": [
[]
]
}
]
The settings.js file is as follows:
adminAuth: {
type: "credentials",
users: [
{
username: "adminuser",
password: "adminpass",
permissions: "*"
},
Hope this helps.

Parsing Twitter Information with jq ("text": null)

I am trying to do some Twitter-analysis via Twurl and extract some information via jq.
I firstly get some tweets via twurl with the command
twurl /1.1/users/search.json?q=judo
Then i used the following line to structure the outpot with jq:
twurl /1.1/users/search.json?q=judo | jq
i get something like this:
[
{
"id": 173752759,
"id_str": "173752759",
"name": "#JudoWorlds πŸ₯‹",
"screen_name": "Judo",
"location": "Worldwide",
"description": "The Official Twitter Account of the International Judo Federation πŸ₯‹",
"url": "https:.....",
"entities": {
"url": {
"urls": [
{
"url": "https://......",
"expanded_url": "https://www.ijf.org/news/show/5-must-see-preliminary-round-clashes-2",
"display_url": "ijf.org/news/show/5-mu…",
"indices": [
0,
23
]
}
]
},
"description": {
"urls": []
}
},
"protected": false,
"followers_count": 59854,
"friends_count": 847,
"listed_count": 529,
"created_at": "Mon Aug 02 07:55:15 +0000 2010",
"favourites_count": 7074,
"utc_offset": null,
"time_zone": null,
"geo_enabled": true,
"verified": true,
"statuses_count": 16532,
"lang": null,
"status": {
"created_at": "Fri Aug 30 08:27:10 +0000 2019",
"id": 1167353053282013200,
"id_str": "1167353053282013184",
"text": "#JudoWorlds The Alternative Promo \n\n#NeilAdamsJudo https://.....",
"truncated": false,
"entities": {
"hashtags": [
{
"text": "JudoWorlds",
"indices": [
0,
11
]
}
],
"symbols": [],
"user_mentions": [
{
"screen_name": "NeilAdamsJudo",
"name": "Neil Adams MBE",
"id": 40488733,
"id_str": "40488733",
"indices": [
36,
50
]
}
],
"urls": [],
"media": [
{
"id": 1167352899267002400,
"id_str": "1167352899267002369",
"indices": [
51,
74
],
"media_url": "http://pbs.twimg.com/ext_tw_video_thumb/1167352899267002369/pu/img/6yD1r7uaPV7p3y6a.jpg",
"media_url_https": "https://pbs.twimg.com/ext_tw_video_thumb/1167352899267002369/pu/img/6yD1r7uaPV7p3y6a.jpg",
"url": "https://......",
"display_url": "pic.twitter.com/0RlLbKLkN8",
"expanded_url": "https://twitter.com/Judo/status/1167353053282013184/video/1",
"type": "photo",
"sizes": {
"thumb": {
"w": 150,
"h": 150,
"resize": "crop"
},
"medium": {
"w": 1200,
"h": 675,
"resize": "fit"
},
"small": {
"w": 680,
"h": 383,
"resize": "fit"
},
"large": {
"w": 1280,
"h": 720,
"resize": "fit"
}
}
}
]
},
"extended_entities": {
"media": [
{
"id": 1167352899267002400,
"id_str": "1167352899267002369",
"indices": [
51,
74
],
"media_url": "http://pbs.twimg.com/ext_tw_video_thumb/1167352899267002369/pu/img/6yD1r7uaPV7p3y6a.jpg",
"media_url_https": "https://pbs.twimg.com/ext_tw_video_thumb/1167352899267002369/pu/img/6yD1r7uaPV7p3y6a.jpg",
"url": "https://.....",
"display_url": "pic.twitter.com/0RlLbKLkN8",
"expanded_url": "https://twitter.com/Judo/status/1167353053282013184/video/1",
"type": "video",
"sizes": {
"thumb": {
"w": 150,
"h": 150,
"resize": "crop"
},
"medium": {
"w": 1200,
"h": 675,
"resize": "fit"
},
"small": {
"w": 680,
"h": 383,
"resize": "fit"
},
"large": {
"w": 1280,
"h": 720,
"resize": "fit"
}
},
"video_info": {
"aspect_ratio": [
16,
9
],
"duration_millis": 48800,
"variants": [
{
"bitrate": 256000,
"content_type": "video/mp4",
"url": "https://video.twimg.com/ext_tw_video/1167352899267002369/pu/vid/480x270/v4nkTg6qs9rpLq8M.mp4?tag=10"
},
{
"content_type": "application/x-mpegURL",
"url": "https://video.twimg.com/ext_tw_video/1167352899267002369/pu/pl/SQN57QxQFYcKWV7l.m3u8?tag=10"
},
{
"bitrate": 2176000,
"content_type": "video/mp4",
"url": "https://video.twimg.com/ext_tw_video/1167352899267002369/pu/vid/1280x720/8cyNocB_8CRjwVCI.mp4?tag=10"
},
{
"bitrate": 832000,
"content_type": "video/mp4",
"url": "https://video.twimg.com/ext_tw_video/1167352899267002369/pu/vid/640x360/uy2U7D_AEmbLdqEK.mp4?tag=10"
}
]
},
"additional_media_info": {
"monetizable": false
}
}
]
},
"source": "Twitter for Android",
"in_reply_to_status_id": null,
"in_reply_to_status_id_str": null,
"in_reply_to_user_id": null,
"in_reply_to_user_id_str": null,
"in_reply_to_screen_name": null,
"geo": null,
"coordinates": null,
"place": null,
"contributors": null,
"is_quote_status": false,
"retweet_count": 4,
"favorite_count": 17,
"favorited": false,
"retweeted": false,
"possibly_sensitive": false,
"lang": "en"
},
"contributors_enabled": false,
"is_translator": false,
"is_translation_enabled": false,
"profile_background_color": "0099CC",
"profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png",
"profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png",
"profile_background_tile": false,
"profile_image_url": "http://pbs.twimg.com/profile_images/1057928008797970433/O3l2sKj0_normal.jpg",
"profile_image_url_https": "https://pbs.twimg.com/profile_images/1057928008797970433/O3l2sKj0_normal.jpg",
"profile_banner_url": "https://pbs.twimg.com/profile_banners/173752759/1565853008",
"profile_link_color": "0C3C42",
"profile_sidebar_border_color": "8F320A",
"profile_sidebar_fill_color": "F2CF41",
"profile_text_color": "000000",
"profile_use_background_image": true,
"has_extended_profile": false,
"default_profile": false,
"default_profile_image": false,
"following": false,
"follow_request_sent": false,
"notifications": false,
"translator_type": "none"
},
Because i am only interested in certain informations i tried to get the name and the text of the tweet with the following command:
twurl /1.1/users/search.json?q=judo | jq ".[] | { name: .name, text: .text }"
and i get this:
{
"name": "#JudoWorlds πŸ₯‹",
"text": null
}
{
"name": "#WeAreGBJudo",
"text": null
}
{
"name": "CBJ",
"text": null
}
{
"name": "Santos Futebol Clube",
"text": null
}
{
"name": "Marius Vizer",
"text": null
}
{
"name": "FF Judo",
"text": null
}
{
"name": "Santos FC πŸ‡Ί πŸ‡Έ πŸ‡¬ πŸ‡§ ",
"text": null
}
{
"name": "USA Judo",
"text": null
}
{
"name": "ε…¨ζ—₯ζœ¬ζŸ”ι“ι€£η›Ÿ -ゴジラジャパン-",
"text": null
}
{
"name": "Vila Belmiro",
"text": null
}
{
"name": "Deutscher Judo-Bund",
"text": null
}
{
"name": "Bruno Secco",
"text": null
}
{
"name": "Bobby Judo",
"text": null
}
{
"name": "African Judo Union",
"text": null
}
{
"name": "JudoInside.com",
"text": null
}
{
"name": "For competitive judo",
"text": null
}
{
"name": "Judo Canada",
"text": null
}
{
"name": "Neil Adams MBE",
"text": null
}
{
"name": "Sophie Cox",
"text": null
}
{
"name": "Galatasaray Judo",
"text": null
}
Why is this and how can i fix it?
I tried other commands like :
twurl /1.1/search/tweets.json?q=afd | jq ".[] | { name: .name, text: .text }"
but got the error
jq: error (at <stdin>:0): Cannot index array with string "name"
If you need nested 'text' value from 'status' field you should use:
.[] | { name: .name, text: .status.text }
Or shorter version:
.[] | { name, text: .status.text }