Can not send POST request in Postman - rest

My POST request body (raw form) in Postman looks like -
{
"issueDescription" : "New issue reported",
"type" : "Managed services",
"priority" : "LOW",
"description" : "This is a TEST, please ignore",
"contactEmail" : "some.one#somewhere.com",
"contactName" : "abc",
"partnerTicketID" : "IN00012345"
}
I have Header specified as 'Content-Type = 'application/json'
The URL/endpoint is correctly specified - 'https://somecompany.com/rest/incident/
When clicked 'SEND', it gives following error (response) -
//
<rsp code="error">
<msg>The Object passed in should not be null.</msg>
</rsp>
//
What am I doing wrong?

Would you be able to provide more information about the endpoint you're sending the request to? What kind of object is it expecting? Is it expecting a json string?

The rest/incident/API method returned an error message specifying that The Object passed in should not be null.
But that error message is very vague and you haven't included the API method code, so we can't tell you which property should be specified.
I recommend that you either read the API code or talk to the developer responsible for that code to understand which property you should specify.

Related

Can you pass a TJSONObject in REST Debugger

No authentication is required to call this REST service that was created with Delphi.
The client Classes API documented (ClientClassesUnit1.pas).
function TGeneralClient.UpdateCIM2(PostData : TJSONOjbect; const ARequestFilter:string):string
begin
if FUpdateCIM2Command = nil then
begin
FUpdateCIM2Command := FConnection.CreateCommand;
FUpdateCIM2Command.RequestType := 'POST';
FUpdateCIM2Command.Text := 'TGeneral."UpdateCIM2"';
FUpdateCIM2Command.Prepare(TGeneral_UpdteCIM2);
end;
FUpdateCIM2Command.Parameters[0].Value.SetJSONValue(PostData,FInstanceOwner);
FUpdateCIM2Command.Execute(ARequestFilter);
Result := FUpdateCIM2Command.Parmeters[1].Value.GetWideString;
end;
But I would like to create a test using the Delphi REST Debugger and I cannot determine what the settings in the utility should be ... or even if the REST Debugger is capable of doing it. Postman tool doesn't seem to work either.
I tried to post a picture but can't because of company policy restrictions.
Method: POST
URL: https://wxdf0-servername.com/snap4.dll/datasnap/rest/TGeneral/UpdatCIM2
Content type: application/json
Custom body (edited)
{
"data" :{
"Stage" :"7",
"Step" :"1"
}
}
All I get in return on the debugger is "500 :Internal Server error"
What is the proper setup (if possible) to make a call to a Delphi REST call that uses TJSONObject as a parameter?
An object in JSON is surround by { } which you have omitted. As well, properties are separated by a comma.
{
"data": {
"Stage": "7",
"Step": "1"
}
}

How to pass Json Request body from one HttpRequest as a value in the next http request?

I'm trying to capture payload (in JSON) created from an HTTP request and pass it as a value to the next API request.
Step1: Create Http Request Payload. Sample Below:
{
"fdCustomerId":"${cuid}",
"account":{
"type":"CREDIT",
"credit":{
"cardNumber":"ENC_[${Output2}]",
"nameOnCard":"John Smith",
"cardType":"${cardtype}",
"cardSubType": "${cardsubtype}",
"billingAddress":{
"type":"work",
"country":"US",
"primary":true
}
}
Step2: Capture the final Payload into a variable using post processes
var requestBody = ctx.getCurrentSampler().getArguments().getArgument(0).getValue();
vars.put("requestBody", requestBody);
log.info("###########################################Request Body are:##########" + requestBody);
Step3: Pass the RequestBody variable as a value to the next HTTP request
{
"category": "GBS_ExecMetrics_UCom",
"consumed": false,
"data": { "Test Case Id": "AB_CMS_006_CC_001_500_",
"Account Number": "0001210520779700304",
"Primary Card Number": "**${requestBody}**",
"Secondary Card Number": "0000377883144114646",
"Run Date Time": "03/26/201917:30"}
}
When I hit that to the endpoint I get below error message:
{"Error":"BadRequest: Please provide a valid Json"...
How to convert this to string or include escape characters with a function and pass the request-body?
My bad with the sample request syntax taken in step 1.Above steps worked as-is.
Corrected the syntax as below and was able to pass the json. Thanks.
{
"fdCustomerId":"${cuid}",
"account":{
"type":"CREDIT",
"credit":{
"cardNumber":"ENC_[${Output2}]",
"nameOnCard":"John Smith",
"cardType":"${cardtype}",
"cardSubType": "${cardsubtype}",
"billingAddress":{
"type":"work",
"country":"US",
"primary":true
}
}
}
}

update youtube live stream privacy status

I'm trying to update the privacy status of a LiveBroadcast in scala (using the java jdk). This is my workflow:
Create a LiveBroadcast with private privacy status
val snippet = new LiveBroadcastSnippet()
.setTitle(title)
.setScheduledStartTime(YouTubeDateTime.now())
.setChannelId(channel.getId)
val status = new LiveBroadcastStatus()
.setPrivacyStatus("private")
val broadcast = new LiveBroadcast()
.setKind("youtube#liveBroadcast")
.setSnippet(snippet)
.setStatus(status)
val request = youtube.liveBroadcasts()
.insert("snippet,status,contentDetails", broadcast)
request.execute
Transition the LiveBroadcast to testing (iff the bound LiveStream is active)
val request = youtube.liveBroadcasts
.transition(lifeCycleStatus.toString, broadcast.getId, "status")
request.execute
Once happy with the stream, set the LiveBroadcast privacy to public
val status = new LiveBroadcastStatus().setPrivacyStatus("public")
broadcast.setStatus(status)
val request = youtube.liveBroadcasts.update("status", broadcast)
request.execute()
The last part does not work, instead returns a 400 response:
400 Bad Request
{
"code" : 400,
"errors" : [ {
"domain" : "youtube.part",
"location" : "part",
"locationType" : "parameter",
"message" : "{0}",
"reason" : "unexpectedPart"
} ],
"message" : "{0}"
}
Doing the same request here works, so I'm not sure what I'm doing wrong.
Can anyone help?
I might be wrong but I think you should also add id parameter in your LiveBroadcast request. It's the ID that YouTube assigns to uniquely identify the broadcast.
You may want to follow the guidelines on how to create and manage a live broadcast as discussed in Life of a Broadcast wherein it was also mentioned that in processing the API response when setting up your broadcast:
Your code should extract and store the id from that resource as you will need that value to identify the broadcast in future API requests. (You can also identify the video resource that corresponds to the liveBroadcast resource using the same ID.)
In addition to that, encountered error 400 Bad Request with the specified detail unexpectedPart, as described from the common requests errors in YouTube Data API - Errors, means that:
The request's part parameter specifies an unexpected value.

Ink Filepicker convert - The FPFile could not be converted with the requested parameters

I have an application setup in Filepicker. This application uploads directly to my S3 bucket. The initial pickAndStore() function works well. The follow up convert function always fails with the 403 error "The FPFile could not be converted with the requested parameters". I have the following code:
try {
filepicker.setKey(apiKey);
filepicker.pickAndStore(
{
extensions : [ '.jpg','.jpeg','.gif','.png' ],
container : 'modal',
services : [ 'COMPUTER', 'WEBCAM', 'PICASA', 'INSTAGRAM', 'FACEBOOK', 'DROPBOX' ],
policy : policy,
signature : signature,
},
{
location : 'S3',
multiple : false,
path : path,
},
function(InkBlobs){
filepicker.convert(
InkBlobs[0],
{
width : 150,
height : 150,
fit : 'max',
align : 'faces',
format : 'png',
policy : policy,
signature : signature,
},
{
location : 'S3',
path : response.path + fileName + '.png',
},
function(InkBlob) {
console.log(InkBlob);
},
function(FPError) {
console.log(FPError);
}
);
},
function(InkBlobs){
console.log(JSON.stringify(InkBlobs));
}
);
} catch (e) {
console.log(e.toString());
}
The error handler function is always called. The raw POST response is...
"Invalid response when trying to read from
http://res.cloudinary.com/filepicker-io/image/fetch/a_exif,c_limit,f_png,g_face,h_150,w_150/https://www.filepicker.io/api/file/"
...with the rest of my credentials appended. The debug handler returns the previously mentioned message with the moreInfo parameter pointing to a URL "https://developers.filepicker.io/answers/jsErrors/142" which has no content on it about the error.
I thought the problem might be that using S3 directly means the file is not present on the Filepicker system to convert. I tried using the standard pick() function without any S3 uploading and then converting the resulting InkBlob. That produced exactly the same error message.
Any help would be appreciated.
In this instance, the error is in the use of faces and fit max. When using faces, you can only set fit to crop.
The interpretation in the command above is to find the faces, but set the image to fit the max allowed size.
Try removing the "path" option in the policy.
Specifying the path in the policy works well for pickAndStore(), though if you specify a path in your policy for convert, filepicker will give you a 403 error adressing the conversion parameters. Seems like the API won't know if it's the source or destination path.

How to handle json payload in GET request Play 2.0 + Scala

I want to make a handler/controller for a GET request such as in ElasticSearch :
$ curl -XGET 'http://localhost:9200/twitter/tweet/_search?routing=kimchy' -d '{
"query": {
"filtered" : {
"query" : {
"query_string" : {
"query" : "some query string here"
}
},
"filter" : {
"term" : { "user" : "kimchy" }
}
}
}}
I read the documentation from http://www.playframework.org/documentation/2.0.4/ScalaJsonRequests but the example is based on POST request. I've tried on my own it appears that I can access to the body request with POST request. But, when I try with the GET request, my request.body is AnyContentAsEmpty.
Is there a way to handle the json from this request in Play 2.0 ?
I saw that there is no body semantic for GET : Payloads of HTTP Request Methods .
So maybe it's normal that there is no mechanism to deal with it through Play 2.0.
I believe you are confused on what can you expect on each type of request. To sum it up:
GET requests contain the payload in the URL, no request body is
added
POST requests add the payload to the request body
From the example you post it seems that you want to return a Json answer as a result from a GET request, which would make more sense.
That can be easily achieved by crafting the Json string and using the Ok(result).as("application/json") to set the MIME type of the response.
this is a sample question
Play's default body parser follows the HTTP spec, and ignores the message body for GET, DELETE, HEAD and OPTIONS methods. If you want to force it to parse a body, you can do that by explicitly passing a body parser, eg:
def delete = Action(parse.json) { implicit request =>
val json = request.body
val someProp = (json \ "someprop").as[String]
Ok(s"Prop is: $someProp")
}