I have a few test steps set up in SOAPUI with a property transfer step in between to transfer the sessionkey from one response to the next. The problem is, that the response is putting "" around the session key, and these need to be removed in the property transfer.
I used to have a working script that did just that:
def response = messageExchange.responseContent
response = response.replace("""","")
messageExchange.modelItem.testStep.testCase.setPropertyValue("jsonResponse",response)
However, this is no longer working and gives the following error: "Content not allowed in prolog".
Has anyone got any idea what causes this? It was working fine, but after having used SOAPUI for a few years, its now throwing this error..
Thanks!
Related
I am trying to console the data from "https://pokeapi.co/api/v2/pokemon" using HTTPS GET request but the console gives the following error:
Error I am getting while making the GET request
This is my code:
Code
I make the use of HTTPS Get request method to get the data and was expecting to get the JSON but couldn't.
res.on('data') provides a stream of data. This means that it sends parts of the request one at a time. When using the https lib you could add the responses one by one to a string and then parsing everything in res.on('end'). I would suggest though using an easier HTTP library, for instance I really like using axios. If you cannot figure out how to use res.on('data' and res.on('end' let me know and I'll type up an example for your situation.
Found the answer here:
How to get data out of a Node.js http get request
I am trying to access the 'successURL' element of a response payload in chrome console, but cannot work it out. I've tried everything I can think of --> payload.successUrl, e.payload.successUrl, data.payload, but can't seem to access the element.
Anyone able to help? Thanks!
As you shown on image attached to your question - you have successfully accessed this in chrome console :)
You can now right-click to see context-menu and copy it to a variable or do some other things.
But If what you mean is to access data from developer tools straight away in a script - it's rather impossible.
For more information on that - read this aswered here: https://stackoverflow.com/a/50571792/3054380
If the request resulting with that payload data was made by your script - then you need to show how you did this - and surely it is quite simple to access any data recieved in response.
I found the answer in my question from webdev-dan and Tch (I can't upvote them as I don't have the reputation, sorry!). I was trying to access the response after it was posted to console as opposed to parsing the data in my script then sending to console.
Here is what I did to get the element from the response I needed (successUrl).
Javascript
const result = await frui.getSession();
console.log(result);
console.log(result.payload);
console.log(result.payload.successUrl);
Response in console
I'll now set the result.payload.successUrl as a variable to use later on.
I want to read a specific value in the XML returned by the APIC Invoke policy (from a SOAP service), in a gateway script.
I have searched high and low. I have tried this and that from my searches. Result: I failed miserably.
I thought apim.readInputAsXML(function(error, xmlNodelist) was the answer, but was puzzled when I realised that I was reading the input to the API. I'm new to JavaScript and have concluded that 'xmlNodeList' I was processing was actually created by the 'readInputAsXML' (and not one I thought I was passing as parameter) Duh! I suppose the word 'input' gives it away.
I have found 'readAsXML()', but not what kind of object it operates on.
var xmlNodeList = apim.getvariable('response.body')
seemed to work at first, and the type is 'object Nodelist', the same as when using 'readInputAsXML'.
However, the object returned by 'xmlNodelist.item(0)' is a blob (type=13). This contrasts with 'readInputAsXML', where this is a node with name 'Envelope'.
Can anyone help with an explanation or pointing me at a reference?
BTW, this is APIC 2018.3.7
I came across a similar situation. Most likely the respone in api comes without a header, the content-type, so apiŃ does not know how to parse it. I advise that the response to api comes with content-type header. To access the message body, use the context variable message.body, which before the invocation contains the request, after the response.
I'm trying to enter data into a table using REST (WCF CORS) call from an ASP.NET page via jquery/javascript. The initial call works perfectly. Once I get the record key, i know the call is good, and I fire a toast message that indicates such, then i clear the text boxes to allow another re-entry.
On the second entry, once the info is filled out and passes validation. I get this error in Chrome
No 'Access-Control-Allow-Origin' header is present on the requested
resource. Origin 'localhost' is therefore not allowed
access. The response had HTTP status code 400.
- You can see the first call is succesfully, but then the 2nd fails with the above error. It seems i have CORS set up correctly since i'm able to make the initial call successfully. I've even tried a redirect, and it only works for the first entry. In order to get another successful post I must 'physically' refresh the page, then reenter that data.
Any ideas here? Thanks in advance!
UPDATE: this only appears to be an issue in Chrome v 38.02.2125.111. IE 11.0.9600 works fine.
UPDATE 2: this appears to be an issue with the URL length.... i think...
UPDATE 3: it appears there is a 310 character limit for URIs? Anyone know how to get around that?
Recently I started facing issue with one of my scripts that loads a json response from the server. I am using jquery.ajax() to make an ajax call. The code snippet is so -
var request = $.ajax({
url: "script.jsp",
type: "POST",
dataType: "json",
success: function(response) {
console.log(response);
},
error: function(response, error) {
console.log(response, error);
}
});
As I mentioned this script worked as recent as yesterday. I have not made any changes to either the server-side code or the front-end code. The json response is a bit large ~1 MB in size. But I validated the json output using -
python -mjson.tool < output.json
It prints out properly. Curious thing is FF & Chrome handle it differently.
In FF, I open firebug and see the ajax request being made. I see that the request is served in around 300ms but the loading wheel next to the link in the console is still animating for aorund 20 seconds. And after that the json response is properly processed and the result can be seen on the page. In IE also similar behavior, proper processing of the json after 20 seconds.
In Chrome, nothing happens for around 20 seconds after which I see an error in the console saying either "error": undefined or Failed to load resource. Alternatively it also prints the below stacktrace -
POST script.jsp
f.support.ajax.f.ajaxTransport.sendjquery.min.js:4
f.extend.ajaxjquery.min.js:4
DataTableWidget.extend._fetchBuildingBlockItemsPermissionBBItemsWidget.js:91
(anonymous function)PermissionBBItemsWidget.js:83
e.extend.eachjquery.min.js:2
DataTableWidget.extend._loadDataPermissionBBItemsWidget.js:82
DataTableWidget.extend.showPermissionBBItemsWidget.js:15
(anonymous function)permission-building-blocks.html:451
xLAB.min.js:5
ULAB.min.js:5
jLAB.min.js:5
ILAB.min.js:5
eLAB.min.js:5
a.onload.a.onreadystatechange
I dont understand this weird behavior in different browsers.
So in essence I made sure that -
Server side code returns the response fast. I put in some debug statements and saw the server log. None of the response form server take more than 500ms.
Made sure than json is properly validated. The fact that after 20 secs it is processed in both IE & FF without any issues is a proof of that. In addition to use of python's json.tool.
Set the dataType to json
So any pointers on the issue will be a great help. Thanks.
UPDATE
One more curious thing I noticed. While the request is being processed and I hit the refresh button even within 3 seconds of the original request, the process immediately completes. As in I see changes in the view of course fraction of a second later the page is wiped out due to refresh event.
UPDATE 2
I have noticed that after I slice up my big response by alphabets. The issue of looong response happens in only certain responses. I ran this split long response files through http://jsonformatter.curiousconcept.com/#jsonformatter and although it immediately returns saying that the josn is valid, it takes 20+ seconds to actually pretty print the response. I think the problem is happening due to certain characters like \u0026 so with this added info, how to resolve the problem? Here is the snipet of the problematic json.
I figured out the problem. The issue was with how the server-side code provided the client-side code JavaScript with the json string.
I was using a legacy method in our code base which actually rendered the already json string in a jsp page before passing it to the client. This was somehow screwing up the response. Also response type was text/html because of this.
As soon as I switched the response to be of actual application/json MIME type stream, everything was fine.
does your JSON have line feeds? Do you have Firebug or something line that open? The browser may be loading the JSON just fine, it might be your debugging tools crapping out. I Recall having issues before with inspecting certain JSON strings with certain tools just because it didn't have line feeds (or line feeds as understood in Windows). I'm wondering if the fact your logging the whole thing to the console doesn't have something to do with it.