Uploading a file through CKAN's API (1.8): How to do it? - json

I am trying to automate dataset and resource uploading in my CKAN instance. I am using Ubuntu Linux 10.04 64-bit and my CKAN instance version is 1.8.
I can create a new dataset using the command like like so:
$ curl http://ckan.installation.com/api/rest/dataset -H "Authorization:<my api key>" -d '{"name": "dataset-name", "title": "The Name of the Dataset"}'
{... JSON text recieved in response, including the id of the dataset ...}
Now, how do I go about creating and uploading resources (like image files) in my CKAN instance using the command line?
Thanks!

Uploading a file through the FileStore API is somewhat complicated. You'll be better reusing ckanclient's upload_file method. A simple Python script that uses this could solve your problem of uploading from the command-line.
Or, if you're feeling brave, that's the best place to start understanding how to upload a file using cURL.

Related

Error `Unable to find a template property named $schema.` when trying to decompile JSON into Bicep

I'm playing with Azure Bicep and I was expecting that I can take practically any ARM JSON template and translate it into Bicep. I'm intentionally using the word "translate" instead of "decompile" here, because the JSON template was not originally created with Bicep, so it was not compiled from Bicep to JSON in the first place.
I'm creating a VM deployment in the Azure Portal and when it's successfully deployed I download the JSON template (deployment.json and deployment_operations.json).
Then I run the following command:
bicep decompile deployment.json
The command fails with the following error message:
/deployment.json: Decompilation failed with fatal error "[1:1]: Unable to find a template property named $schema."
What should I do to resolve this error?
Bicep CLI version 0.13.1 (e3ac80d678).
PS The VM deployment is the simplest possible Windows Server VM with no data disks and extra features. Created via Azure Portal by clicking Next-Next-Create.
It appears that I've found the solution when writing the question. I was downloading and trying to decompile a wrong file.
The problem was that I was downloading the deployment.json file instead of an actual template file template.json. You need to click Download on the Template tab.
So instead of downloading the from the Overview tab, click the Template tab and then click Download. Or use the Save-AzResourceGroupDeploymentTemplate PowerShell cmdlet.
Similar problem, same solution: https://github.com/Azure/bicep/issues/5237

Modify an etherpad instance with command line tool

Most instances of Etherpad accept setting the entire file by uploading an HTML file. Is there a way to automate this process with a command line tool such as cURL ?
You can use the HTTP API to create or change the content of a pad. There are several client libraries available.

##[error]Error: NO JSON file matched with specific pattern: **/appsettings.json

I'm trying to deploy an Azure App Service using Azure Devops.
I'm using the Task Azure App Service deploy version 4.*
I started noticing the following error in the log recently with the deployment failing (saw it first on 24th September)
Applying JSON variable substitution for **/appsettings.json
##[error]Error: NO JSON file matched with specific pattern: **/appsettings.json.
In the pipeline I use the task Extract files to extract *.zip, then use the result to search for **/appsettings.json.
The same task was running fine till a few days ago.
I tried redeploying an old release which was successful earlier, but it failed now with the same above error.
I double checked, there was no changes done in the pipeline recently for this to break.
How can I fix this.
Turns out my issue was not with the task Azure App Service deploy, but with the task Extract Files.
A rough look on my pipeline is as below:
Before the fix
Extract files
Deploy Azure App Service
The JSON variable substitution failed because the Extract files task was not able to find *.zip files in the root folder and hence extracted nothing. So, there was no appsettings.json file in the folder structure at all.
The Fix
Update the Extract files task search pattern as **/*.zip
Now my pipeline looks like below.
Extract files
Deploy Azure App Service
It now works fine for me.

How to provide JSON inside AWS CLI SNS message?

How to send via aws cli exact JSON structure in command line (NOT via file):
aws sns publish --topic-arn "arn:aws:sns:us-east-1:12345:myproject_serverlessscheduler_sns" --message '{"key1":"value1", "key2":"value2"}' --profile myprofile
Is this above a correct structure of JSON provided directly inside command line?
The JSON structure you provided is the correct way of passing JSON inside AWS CLI for SNS.
I tested on my test environment as shown below and confirmed to be working 100% :

curl not piping to file when querying the google maps api

I am working on a ruby application that uses the geocoder gem to generate location information from addresses. I am trying to use webmock to stub out calls to the api during testing.
Webmock has the option of creating a mock response from a file and has an explanation of how to replay responses recorded with curl -is
https://github.com/bblimke/webmock#replaying-raw-responses-recorded-with-curl--is
I have previously got this to work with different urls but not when trying with the following command.
curl -is http://maps.googleapis.com/maps/api/geocode/json?address=Falmouth,%20Cornwall&language=en&sensor=false > other.txt
When I run the above command all the data I want is outputted to the terminal correctly but nothing at all written to file. I have tried with the --no-keepalive option but that does not fix it
The example in the webmock readme uses I/O re-direction to write the result to a text file. Is that what you are missing? So shouldn't your curl command looks like:
curl -is http://maps.googleapis.com/maps/api/geocode/json?address=Falmouth,%20Cornwall > my_text_file.txt ?