I try to write a Pre-request script in Postman. I want to to make a request so I try to use pm.sendRequest. For example :
pm.sendRequest('http://example.com', function (err, res) {
//...
});
But I get this error :
There was an error in evaluating the Pre-request Script: pm is not defined
I'm on Windows 10. I just updated the extension.
How do I access pm?
A member posted an answer but, for some reason, I think he got banned. His answer didn't have a lot of details, but was working :
You have to use the standalone version of Postman for the pm to be accessible. I was using it as a Chrome extension. By switching to the standalone version, it worked. I don't know why, though.
If you are running an old version of Postman, you may run into this issue as I did. From https://www.getpostman.com/docs/v6/postman/scripts/test_examples#older-style-of-writing-postman-tests
The older style of writing Postman tests relies on setting values for the special tests object.
If you are running an older version of Postman, you will not have the pm object available for use.
For extension version, you can use following pattern:
tests["Status code is 200"] = responseCode.code === 200;
If you guys are using the Desktop version 0f Postman (in my case MacBook desktop version),
Then,
use responseBody instead of pm.response.text()
to set global variable postman.setGlobalVariable() instead of pm.environment.set()
Sample:
var jsonData = JSON.parse(responseBody);
postman.setGlobalVariable("studentId", jsonData.studentId);
You can use SNIPPETS to auto-generate basic things like the above to avoid these errors.
My Postman version detail:
Postman for Chrome
Version 5.5.6
OS X / arm64
Chrome 108.0.0.0
Replace pm with postman, it should work fine.
Related
I am quite new to RN . I know this question is being repeated but I didn't quite get ans I was looking for there .
So my current project uses
expo for web and react-native cli for the android set up .
I want to add an image-picker to the project.
I see two options at my side .
RN-image-picker
expo-image-picker
I have some issues and some questions !!
Is RN-native-image picker comaptible with web ??
I think its not ,there are two resons I think that ,this lib uses Nativemodules, which
won't be bundled for web and its giving undefined error for NativeModules when I run with
web while it works fine on android .
Should I use expo-image-picker when I am creating a android build with react-native cli ??
The build doesn't give errors and it shouldn't ,but when I click on upload image ,app
crashes after I select image.I read the docs and github for the issue.Many people pointed
out its ram allocation issue,which can be sorted with disbaling "Dont keep activities" in
developer's option,which I haven't tried yet .
Also on web ,the following code snippet returns base64 as uri,is it default behaviour ??
I am using this code snippet for expo-image-picker,which ends up crashing app when I build app with rn cli,but doesn't seem to cause issues with expocli build.But I want to use expo for web and rn for android.
Also on web ,the following code snippet returns base64 as uri,is it default behaviour ??
const pickImage = async () => {
try{
let result = await ImagePicker.launchImageLibraryAsync({
mediaTypes: ImagePicker.MediaTypeOptions.Images,
allowsEditing: true,
aspect: [4, 3],
quality: 1,
base64:false
})
if(!result.isCancelled)return result.uri ;
}catch(err){
console.log(err) ;
}
}
So what should I do in this case,use expo-image-picker as it seems to be compatible with all platforms/both ?
Any kind of input would be helpful !!
I'm not a fan of Expo, and I don't have experience with that but I try to answer to your question that can be.
Is RN-native-image picker comaptible with web ??
You have right, the library supports only mobile devices.
Should I use expo-image-picker when I am creating an android build with react-native cli ??
From expo documentation, I read that but I know also that sometimes the rn-cli and expo has some package differences, and this answer proves that.
Expo never locks you in, you can "eject" at any time and your project will just be a typical native project with the React Native and Expo SDK packages that your app is using installed and configured.
I don't know what the exception, and maybe the solution that you put in your answer work well, but maybe is possible to have some dependency mismecc? Such as a none object on the Web app? or something like that.
Also on web ,the following code snippet returns base64 as uri,is it default behaviour ??
This looks like be an bug and this issue on github maybe can confirm my idea
I recently started using commandBox to run ColdFusion in my local environment. After I played around for a while one issue I run into was related to adminapi. Here is the code that I use in one of my projects:
adminObj = createObject("component","cfide.adminapi.runtime");
instance = adminObj.getInstanceName();
This code is pretty straight forward and work just fine if I install traditional ColdFusion Developer version on my machine. I tried running this on commandBox: "app":{ "cfengine":"adobe#2018.0.7" }
After I run the code above this is the error message I got:
Object Instantiation Exception.
Class not found: com.adobe.coldfusion.entman.ProcessServer
The first debugging step was to check if component exists. I simply checked that like this:
adminObj = createObject("component","cfide.adminapi.runtime");
writeDump(adminObj);
The result I got on the screen was this:
component CFIDE.adminapi.runtime
extends CFIDE.adminapi.base
METHODS
Then I tried this to make sure method exists in the scope:
adminObj = createObject("component","cfide.adminapi.runtime");
writeDump(adminObj.getInstanceName);
The output looks like this, and that confirmed that method getInstanceName exists.
function getInstanceName
Arguments: none
ReturnType: any
Roles:
Access: public
Output: false
DisplayName:
Hint: returns the current instance name
Description:
The error is occurring only if I call the function getInstanceName(). Does anyone know what could be the reason of this error? Is there any solution for this particular problem? Like I already mentioned this method works in traditional ColdFusion 2018 developer environment. Thank you.
This is a bug in Adobe ColdFusion. The CFC you're creating is trying to create an instance of a specific Java class. I recognize the class name com.adobe.coldfusion.entman.ProcessServer as being related to their enterprise manager which controls features only available in certain versions of CF as well as features only available on their "standard" Tomcat installation (as opposed to a J2E deployment like CommandBox).
Please report this to Adobe in the Adobe bug tracker as they appear to be incorrectly detecting the servlet installation. I worked with them a couple years ago to improve their servlet detection on CommandBox, but I guess they still have some issues.
As a workaround, you could try and find out what jar that class is from on a non-CommandBox installation of Adobe ColdFusion and add it to the path, but I can't promise that it will work and that it won't have negative consequences.
As of version 3.0 the App Insights API is deprecated.
Unfortunately I rely heavily on the app_event node to fetch information about the revenue. The code for that looks like this:
requests.request(
"GET",
"https://graph.facebook.com/v2.12/" + str(app_id) + "/app_insights/app_event/",
params={
"since":d1.strftime("%s"),
"until":d2.strftime("%s"),
"summary":"true",
"event_name":"fb_ad_network_revenue",
"aggregateBy": "SUM",
"breakdowns[0]":"placement",
"access_token": app_access_token
}
)
For new Apps I can't use this code anymore because the Graph API does not support it anymore:
The app tried to call version v2.12. This app can only call versions
v3.0 and higher, so the request defaulted to version v3.0.
How could I possibly port my code to version 3.0?
I ran into this problem as well. It looks like you can use the adnetworkanalytics endpoint now for this query. The parameters and data returned are of course slightly different than the app_event endpoint. Hurray for progress I guess.
Here are the docs:
https://developers.facebook.com/docs/audience-network/reporting-api
How to set setTimeout/Thread.sleep in newman(postman's node module).
I am using below function :
setTimeout(function(){
console.log('sleep for ten min');
}, 600000);
Above function works perfectly in collection runner of postman.
But when I tried newman it is throwing error as
'setTimeout is not available inside sandbox and has no side-effect.'
I have found a similar thread like below:
https://github.com/postmanlabs/newman/issues/304
But they also haven't provided any solution.
Is there anyway by which I can mark my single API to delay for a time period.
I am already using Newman parameter --delay-request 60000 which delay between API's so it won't work for it.
Any solution will be helpful
Update newman to 3.8.3 or later.
The older version of newman is not supporting setTimeout
So opening the link you've given to us they say :
So to be clear, you are going to use newman a way it's not designed for.
This being said, you can try to implement a custom sleep :
function sleep(milisecond) {
const date = Date.now();
// Sleep in an *infinite* loop
while ((date + milisecond) > Date.now());
}
I have a GWT application http://islamart.tn which fails on google crawling :
The 'fetch as google' feature fails with a 'partial' status saying that it can't find undefined.cache.js
After some research, I found that this js is the app js when the user.agent is not recognized
I therefore changed my
UserAgentPropertyGenerator.UserAgent
enum value for gecko to recognize google bot:
gecko1_8("return (ua.indexOf('Googlebot') || ua.indexOf('gecko') != -1 || docMode >= 11);");
In my core GWT module I naturally added the line :
<property-provider name="user.agent" generator="fr.onevu.vume.client.common.UserAgentPropertyGenerator"/>
I installed 'Chrome UA spoofer" to emulate the Googlebot user.agent request, and what happened is that now I have a warning at startup saying that the runtime value safari is different than the compile time gecko_18
I still see some checking runtime code in the generated js
{$stackDepth_0=stackIndex_0-1;return 'gecko1_8'}$stackDepth_0=stackIndex_0-1;return 'unknown'}
but those files are very large, and I don't know from which classes they are generated.
Additionally, I had to fall back to the version 2.6.1 since compilation with 2.8.1RC1 and 2.7.0 don't finish the job (for some reason I don't have the time to investigate now)
Any ideas please?...
I need an answer to one of these questions :
How to personalize the runtime user agent check generated code ?
How to make googlebot use the gecko_18 version of my app ?