i have started to use Robot Framework 3 months ago and i wish to test an API
i have the request working on my postman but i don't understand how to put it on robot framework
Here's the curl
curl --location --request POST 'MY URL' \--header 'Authorization: Bearer token' \--form 'options="{ \"position\": { \"x\": 10, \"y\": 10, \"width\": 200, \"height\": 50 }, \"page\": 1, \"pageSelectionMode\": \"NEW\", \"lang\": \"fr\", \"fontSize\": 12, \"certificate\": \"MIIFrTCCBJWgAwIBAgIIPWjtiF\" }";type=application/json' \--form 'document=#"path to picture"'
Here's my RFW test
File Should Exist ${fileJsonOption}
Create Session mysession ${SignatureHomepageUrlDEV}
${header} Create Dictionary Content-Type=multipart/form-data Authorization=${bearer}
&{body} Create Dictionary options=${fileJsonOption} document=${filePDFToTest}
${response} Post Request mysession /api-sig/signature/prepare headers=${header} data=${body}
Status Should Be 200 ${response}
Log ${response}
I only have a status code 500 instead of 200
Can you tell me where i'm failling ?
Thank you for your help
Related
The app that I am trying to test has an SFTP server that can be queried via API. Swagger shows the following sample cURL request to get domain files information, and I am having a hard time making this call with Karate:
curl -X GET -H 'Accept: application/json' 'https://{host}:{port}/api/{clientId}/'
I do the following where baseUrl is defined as https://sftp.mydomain.com:22 where 22 is the port number that I can successfully use to connect to the SFTP server via Cyberduck:
Feature:
Background:
* url baseUrl
* def moduleBase = '/api/12345/'
Scenario:
* path moduleBase
When method get
Then status 200
The error that I get is this:
ERROR com.intuit.karate - src/test/java/mytest.feature:9
When method get
http call failed after 815 milliseconds for url: https://sftp.mydomain.com:22/api/12345/
What am I doing wrong?
Clearly it may not be HTTP so I don't think Swagger and all is legit.
Maybe you can just delegate to the OS. Refer: https://stackoverflow.com/a/64352676/143475
We have been using curl with the VSTS / Azure API v5.1 to create testruns, post test results and set testruns with a state of 'completed' for a good while.
For the past few weeks, our requests to patch the testrun state to 'completed' from 'inProgress' are not committed.
(Yet we can use the same request to update other testrun attributes like the value for 'comment')
Documentation still mentions acceptable values to supply for state:
https://learn.microsoft.com/en-us/rest/api/azure/devops/test/runs/update?view=azure-devops-rest-5.1#updating-started-date
Are you able to complete your testruns via the API? Thanks
curl -k -H "Content-Type: application/json" -H "Authorization: Basic {token}" --request PATCH -d "{'state':'Completed','build':{'id': 0},'comment':'an updated comment'}" https://dev.azure.com/etc/etc/_apis/test/runs/{testrunID}?api-version=5.1
I can update the state to Completedsuccessfully via REST API:
PATCH https://dev.azure.com/{organizaion}/{project}/_apis/test/runs/{runid}?api-version=5.1
Request Body:
{
"state": "Completed"
}
But it only updated the test run state, if the result is not Passed, then there will be a triangular exclamation mark near the Completed state.
So, to completely update the state we have to update the test result outcome to Passed :
PATCH https://dev.azure.com/{organization}/{project}/_apis/test/runs/{runid}/Results?api-version=5.1
Request body:
[
{
"id": 100000,
"outcome": "Passed"
}
]
I test with the following script in the PowerShell task of azure devops and can successfully modify the any state of the testrun to Completed .
$connectionToken="your token"
$base64AuthInfo= [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($connectionToken)"))
curl.exe -k -H "Content-Type: application/json" -H "Authorization: Basic $base64AuthInfo" --request PATCH -d "{'state':'Completed','comment':'an updated comment'}" https://dev.azure.com/{org}/{pro}/_apis/test/runs/{runId}?api-version=5.1
Thank you all for your help. I can confirm that our curl command run in CMD is now successfully setting the testrun state to 'completed'. As mentioned earlier, it was able to change other aspects of the testrun record, (eg comment) but for the last few weeks did not affect the state. Now the state is updating too. This would suggest to me the issue probably wasn't our side, as our curl api request hasn't changed. Glad to see it's resolved though.
I'd like to download an attachment from the conversation via REST API (Circuit Sandbox)
If I query the Conversation Item, I can see the attachments and within that the fileID. Then, if I am logged with a user account who is a member of the conversation, I can run the following to download the attachment or paste it in the browser where I am logged to the sandbox:
'''
start chrome https://circuitsandbox.net/rest/v2/fileapi?fileid=MyFileIdHere
'''
And that works. Is there a way to achieve the same with a Bot via REST?
A regular GET request will work.
curl https://circuitsandbox.net/rest/fileapi?fileid=<fileId> \
-H "Authorization: Bearer <ACCESS_TOKEN>"
and here is the REST notation.
GET rest/fileapi?fileid=<fileId> HTTP/1.1
Host: circuitsandbox.net
Authorization: Bearer <ACCESS_TOKEN>
The access token for a bot (client credentials grant) is obtained via OAuth 2.0:
curl https://circuitsandbox.net/oauth/token \
-d 'grant_type=client_credentials&client_id=<CLIENT_ID>&client_secret=<CLIENT_SECRET>&scope=READ_CONVERSATIONS,WRITE_CONVERSATIONS'
REST notation:
POST /oauth/token HTTP/1.1
Host: circuitsandbox.net
Content-Type: application/x-www-form-urlencoded
grant_type=client_credentials&client_id=<CLIENT_ID>&client_secret=<CLIENT_SECRET>&scope=READ_CONVERSATIONS,WRITE_CONVERSATIONS'
I am using REST api of Quickblox. but everytime , i am getting response :
{"errors": {
"base": ["Required session does not exist"]
}}
And i am using below api : url : http://api.quickblox.com/users.json
Data & header is :
curl -X POST \
-H "Content-Type: application/json" \
-H "QuickBlox-REST-API-Version: 0.1.0" \
-H "QB-Token: cf5709d6013fdb7a6787fbeb8340afed8aec4c69" \
-d '{"user": {"login": "xyz", "password": "xyz#123", "email": "xyz#domain.com", "external_user_id": "68764641", "facebook_id": "87964654", "twitter_id": "132132", "full_name": "test 1234", "phone": "87654351", "website": "", "tag_list": ""}}' \
can anybody help me to resolve this error?
When someone connects with an app using QuickBlox, the app has to obtain an access token which provides temporary, secure access to QuickBlox APIs.
A session token is an opaque string that identifies a user and an app.
Session tokens are obtained via Create Session request.
Then, because of privacy checks, all REST API requests must be authenticated with a token - the QB-Token header of each request to REST API must contain valid session token.
Expiration time for session token is 2 hours after last request to REST API. Be aware about it. If you will perform query with expired token - you will receive error 'Required session does not exist'. In this case you have to recreate a session token.
Each REST API response contains header 'QB-Token-ExpirationDate' which contains session token expiration date.
Well ,
i m hitting a simple PhoneVerify Request from my localhost which have enterprise proxy .
i have configured my Proxy setting using below link.
Can't access to production endpoint with WSO2 API Manager - entreprise proxy
But I m Getting The Same Response code 0 and Blank Response Body.
Here Is a the curl and Request URL :
Curl
curl -X GET --header "Accept: application/json" --header "Authorization: Bearer b9d93ac569bec1721716e1422b852b" "https://192.168.78.153:8244/phone/1.0.0/CheckPhoneNumber?PhoneNumber=8888888888&LicenseKey=0"
Request URL
https://192.168.78.153:8244/phone/1.0.0/CheckPhoneNumber?PhoneNumber=8888888888&LicenseKey=0
Response Body
no content
Response Code
0
Response Headers
{
"error": "no response from server"
}
[ base url: /phone/1.0.0 , api version: 1.0.0 ]
Since you are behind a proxy with port set through http.proxyPort, You have to use port 1234 instead of 8244.