How to create address in sawtooth-seth through REST API - rest

I am learning sawtooth-seth. I can create key-pair and account using
seth-cli-go. In order to connect with application I need to connect it with REST API. So I used the following REST API.
curl --data '{"method":"personal_newAccount","params":["test#123"],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST localhost:3030
But I got the following error msg,
{"jsonrpc":"2.0","error":{"code":-32069,"message":"Error generating key"},"id":1}
seth-rpc server error
[00:14:21.966] (7fc28042d700) ERROR Error generating key: No such file or directory (os error 2)
[00:14:21.966] (7fc28042d700) ERROR Error generating key
How to fix this? And where my key-pair will be stored?

How to fix this?
The code which producing that error message can be found here.
According to the code, this error came because it has mismatch key with the system. I think you could try curl with your keypair as well.
And where my key-pair will be stored?
I read the code to find where it stores the key. You can check the implementation of function get_key_dir() in accounts.rs, which states Some([home.to_str()?, ".sawtooth", "keys"].iter().collect())
So, your key-pair should be in your home directory.

Related

Difference in the HTTP Response code is getting observed when executing a POST call from cURL vs Postman for the same negative test condition

Correct URI: https://example.com/a/b/users/111/c
Negative test URI: https://example.com/a/b/users/<111>/c
Sample Request Body:
{
"abc": "xyz"
}
Postman returned 404 with a message that the user doesn't exist, for the negative test URI mentioned above.
Then I executed the cURL generated by the Postman and appended to it "-k" to ignore the certificate verification and "-v" for verbosity. However, cURL returned 500 for the same URI.
The original concern was that there has been a mismatch in the test results when the above API was hit by an automation test using RestAssured vs when manually executing it from Postman. Debugging that has led me to find out the difference in response between Postman and curl as well.
Any thoughts to debug this issue further?
While debugging, I found the URI passed was getting encoded and decoded, and <111> got printed as %3C111%3E at one of the breakpoints. So when I tried sending the encoded URI from cURL like https://example.com/a/b/users/%3C111%3E/c it worked just fine returning 404. However Postman returned 404 both with <111> and %3C111%3E.
Thanks to #derpirscher for providing hints that helped me reach this conclusion.
P.S. For more details, please refer my last comment above.

Unable to import test results to jira via rest api

i'm using the following curl command to import the output.xml file into jira test execution key and receiving error as below. I'm sure the test execution key is existing in jira and the project id is also correct. Any pointers?
curl -H "Content-Type: multipart/form-data" -u userid:pass -F "file=#output.xml" "https://server/rest/raven/latest/import/execution/robot?projectKey=PROJKEY+and+testExecKey=TESTEXNKEY" -o error.txt
The error i receive is as below
The User "userid" does not have permission to create issues
Why does it try to create new issue while the issue already exists? And why does it say the user doesn't have access when the access is there?
You probably mean Xray add-on and you probably use the same request per their documentation. The problem seems to be with your parameter syntax. It should be .../robot/?projectKey=PROJKEY&testExecKey=TESTEXNKEY (i.e. & instead of +and+).
Plus I would explicitly specify it's a POST request: curl -X POST ....
But their error message is not clear, anyway. I don't have Xray available right now, but if you keep having troubles, I would recommend checking with their support.

How to start TensorFlow Serving ModelServer with the REST API endpoint

I'm trying to make use of the new possibility to send HTTP requests to the TensorFlow ModelServer. However, when I try to run the following, it doesn't recognize the --rest_api_port argument:
tensorflow_model_server --rest_api_port=8501 \
--model_name=half_plus_three \
--model_base_path=$(pwd)/serving/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_three/
unknown argument: --rest_api_port=8501
I've encountered the same error. I looked through the source code.
In main.cc file, there is no rest_api_port option in the source code version r1.7 below.
Due to this, if you want to use REST, you need to use tensorflow-serving r1.8 above or implement it your self.
Hope this is helpful to you.

Unable to understand the cURL invocation

I am currently using jpmml openscoring REST API..
I have successfully installed Maven and built the uber-JAR file and I am also able to access
http://localhost:8080/OpenScoring/rules.pmml
I am confused with the instructions given at
https://github.com/jpmml/openscoring.
It says the sample curl invocation is
curl -X GET htttp://localhost:8080/openscoring/model
but I am getting a 404 error when I try to implement this. What does model mean here?
I am getting an output when I implement this:
curl -X GET htttp://localhost:8080/Openscoring/rules.pmml
The /model/ part of the path identifies the resource type. The general formula for the path component of Openscoring service URLs is /<context path>/<resource type>/<resource identifier>/<action>
In your case (assuming that the model identifier is rules.pmml), the correct path component would be /openscoring/model/rules.pmml.
I was getting a 404 error as I did not put my rules.pmml file in the directory which my command prompt pointed to.(This was a very silly mistake)
And thanks to the user Anik Islam Abhi in the comments, I found out what model in the invocation
curl -X GET htttp://localhost:8080/openscoring/model meant.
model is just an Endpoint of the REST source but not a directory in the openscoring folder or any kind of path.

Cannot set more than one Meta data with OpenStack Swift Object

I am trying to set metadata with a Object stored in Swift Container. I am using following command (note that my container is 'container1' and object is 'employee.json':
curl -X POST -H "X-Auth-Token:$TOKEN" -H 'X-Object-Meta-metadata1: value' $STORAGE_URL/container1/employee.json
It works fine with one metadata. But whenever, I am trying to set more than one metadata issuing several curl commands, only the last metadata value is actually set.
I think, there should not be a limit that you can set only one metadata for a swift object. Am I doing anything wrong?
FYI: I am using Havana release of Openstack Swift.
Thank you.
I think, I have figured it out... Its my bad that I did not read documentation sincerely.
It [1] says, "A POST request will delete all existing metadata added with a previous PUT/POST."
So, I tried this and it worked...
curl -X POST -H "X-Auth-Token:$TOKEN" -H 'X-Object-Meta-p1:[P1]' -H 'X-Object-Meta-p2:[P1]' $STORAGE_URL/container1/employee.json
Here, instead of two POST requests, now I have set multiple metadata in a single POST request.
Again, thanks.
Ref:
http://docs.openstack.org/api/openstack-object-storage/1.0/content/update-object-metadata.html