I am trying to obtain the status message of the response to a POST to a rest service via:
var response = UrlFetchApp.fetch(<url>, <params>);
I need the status description as reported by the server which does not appear to be available as part of the HTTPResponse object returned by the fetch method.
I can get the status code using:
response.getResponseCode();
But no luck on the message associated with it. I have wrapped the fetch call in a try/catch block, but the error message returned using that method is an error message provided by the spreadsheet service, not the original, raw status description from the server response.
Any ideas on how to obtain this piece of information, most appreciated.
The associated message from the service should be available in HTTPResponse.getContentText(). You'll need to pass the optional parameter muteHttpExceptions set to true in the UrlFetchApp.fetch() request to prevent an exception from being thrown.
Related
I am trying to create a test plan using jmeter.its for an API Post request, I have a header manager, bodydata, checked for spellings and the syntax seems to be correct. However, Im getting 400 response code with the following error shown in the attached image. Anyone with an idea how I can resolve this? Thank you. the error
Here is the request the request
The user doesn't have to be logged in, i have added a header manager, I have also noticed there header has a cookie value thats hard coded but it appears to be the same in every request. In the UI the API request returns 200 and thats what im expecting with the Jmeter script.
In its current form the question cannot be answered comprehensively.
HTTP Status Code 400 means that
The 400 (Bad Request) status code indicates that the server cannot or
will not process the request due to something that is perceived to be
a client error (e.g., malformed request syntax, invalid request
message framing, or deceptive request routing).
Check that your ${site} and ${csVersion} variables have their respective values using Debug Sampler and View Results Tree listener combination
Cross check headers sent by JMeter and by the "UI", the most important is Content-Type
Use a sniffer tool like Wireshark of Fiddler and capture the requests which are being sent by JMeter and the "UI", the requests must be exactly the same apart from dynamic parameters which need to be correlated
The issues was being caused by an anti-forgery cookie which was hard coded in the request.I used a regex to extract the value from a previous request and used a variable value from the regex to make sure the same value is being passed on to the request that was failing.
We are testing API Automation with Rest Assured in Java.
In Postman, we run API after success gives message as "Record Saved Successfully"
Trying to automate the same. How to validate only message recieve as response in body.
response.then().assertThat().statusCode(200);
.and().body("$", "Record Saved Successfully");
its not working, Please help
Use built-in assertion mechanism:
response
.then()
.assertThat()
.statusCode(200)
.body("message", equalTo("Record Saved Successfully"));
I'm trying to write some tests for api but the problem is the response sent from api is ok only for the first request I sent to api, after that, I get
No content was sent from Yii application error.
The problem is I can't use echo directly in my end function (everything is ok if i use echo) because if the response is too long it will be flushed! and now I'm trying to use
Yii::$app->response;
and try to set my response in
$response->content
but in
Yii2::doRequest //the ob_get_clean()
function returns null after first request and throw the No content exception.
Any idea of how I can fix the problem with codeception?
I have written the following code to connect and retrieve a token from the Autodesk. but this does not work properly:
var client = new RestClient("https://accounts.autodesk.com");
client.Authenticator = OAuth1Authenticator.ForRequestToken(consumerKey, consumerSecret);
var request = new RestRequest("OAuth/RequestToken", Method.POST);
var response = await _client.Execute(request);
Executing the request it throws a bad request exception.
Response status code does not indicate success: 400 (Bad Request).
For consumerKey and consumerSecret I respectively used my email and the associated password that I've already registered in accounts.autodesk.com
How can I understand if I'm sending the request in a wrong format or I just send a wrong consumerKey and consumerSecret. And If they are wrong could you please guide me where I can obtain these parameters from Autodesk?
It's not at all your email and password that you need to use but API keys that are generated from your account on our developer portal.
Please sign up or login to the portal: https://developer.autodesk.com/
And follow the step by step tutorial in order to request a token, there are detailed explanations of the workflow there, it can't be easier than that:
https://developer.autodesk.com/en/docs/oauth/v2/tutorials.
I have created a C# sample and a lib but it hasn't been updated yet to use scopes, you can take a look at the discussion in the issues: https://github.com/Developer-Autodesk/view.and.data-dotnet-wpf.tutorial
Finally we are working on generated wrappers for our REST API's so we will be able to produce more stable samples pretty soon. Check out our blog for upcoming news about that: http://adndevblog.typepad.com/cloud_and_mobile
Say I have "service" returning a XML document:
function doGet() {
var result = '<result>42</result>';
var output = ContentService.createTextOutput(result);
output.setMimeType(ContentService.MimeType.XML);
return output;
}
By default, the HTTP status code for the response will be 200. How can I set it something different, say 500 (while still returning the same XML document)?
This is not currently possible with the ContentService. Implicitly, only the 200 status code can be returned back by the successfully completion of the script. Other error codes are all system level that get raised when something goes wrong.
If you have a good use case for this, please open a feature request in the issue tracker.