var moment = require("moment");
var time = moment().valueOf();
pm.environment.set('time', time);
var eventArray = [];_
for(var i = 1; i <= 50; i++)
{
var t = time + (i * 1000);
eventArray.push({
"eid": i,
"time": t
});
}
var data = { "event": eventArray };
var JSONData = new Buffer(JSON.stringify(data)).toString();
pm.environment.set("JSONData", JSONData);
console.log("JSONDATA", JSONData);
Change your entire request body to the following variable:
{{JSONData}}
This is what would be sent:
{“event”:[{“eid”:1,“time”:1538518294839},{“eid”:2,“time”:1538518295839},{“eid”:3,“time”:1538518296839},{“eid”:4,“time”:1538518297839},{“eid”:5,“time”:1538518298839},{“eid”:6,“time”:1538518299839},{“eid”:7,“time”:1538518300839},{“eid”:8,“time”:1538518301839},{“eid”:9,“time”:1538518302839},{“eid”:10,“time”:1538518303839},{“eid”:11,“time”:1538518304839},{“eid”:12,“time”:1538518305839},{“eid”:13,“time”:1538518306839},{“eid”:14,“time”:1538518307839},{“eid”:15,“time”:1538518308839},{“eid”:16,“time”:1538518309839},{“eid”:17,“time”:1538518310839},{“eid”:18,“time”:1538518311839},{“eid”:19,“time”:1538518312839},{“eid”:20,“time”:1538518313839},{“eid”:21,“time”:1538518314839},{“eid”:22,“time”:1538518315839},{“eid”:23,“time”:1538518316839},{“eid”:24,“time”:1538518317839},{“eid”:25,“time”:1538518318839},{“eid”:26,“time”:1538518319839},{“eid”:27,“time”:1538518320839},{“eid”:28,“time”:1538518321839},{“eid”:29,“time”:1538518322839},{“eid”:30,“time”:1538518323839},{“eid”:31,“time”:1538518324839},{“eid”:32,“time”:1538518325839},{“eid”:33,“time”:1538518326839},{“eid”:34,“time”:1538518327839},{“eid”:35,“time”:1538518328839},{“eid”:36,“time”:1538518329839},{“eid”:37,“time”:1538518330839},{“eid”:38,“time”:1538518331839},{“eid”:39,“time”:1538518332839},{“eid”:40,“time”:1538518333839},{“eid”:41,“time”:1538518334839},{“eid”:42,“time”:1538518335839},{“eid”:43,“time”:1538518336839},{“eid”:44,“time”:1538518337839},{“eid”:45,“time”:1538518338839},{“eid”:46,“time”:1538518339839},{“eid”:47,“time”:1538518340839},{“eid”:48,“time”:1538518341839},{“eid”:49,“time”:1538518342839},{“eid”:50,“time”:1538518343839}]}
Now i need the above request to be converted as jmeter request and pass in a single variable.
The equivalent Groovy code for using in a suitable JSR223 Test Element would be something like:
def events = []
def time = System.currentTimeMillis()
1.upto(50, {
events.add([eid: it, time: time + it * 1000])
})
def JSONData = new groovy.json.JsonBuilder([event: events]).toPrettyString()
vars.put('JSONData', JSONData)
The generated value can be accessed as ${JSONData} JMeter Variable where required
More information:
Apache Groovy - Parsing and producing JSON
Apache Groovy - Why and How You Should Use It
I am using vb 2008 .net 3.5.
I am trying to use sms api.
I have error on httpclient cannot find and I cannot find it on reference.
sms provider code :
HttpClient client = new HttpClient();
Uri baseAddress = new Uri("https://smsmisr.com/");
client.BaseAddress = baseAddress;
var sendtime = DateTime.Now.ToString("yyyy-MM-dd-HH-mm");
HttpResponseMessage response = client.PostAsJsonAsync(
"api/webapi/?" +
"username=XXXxx" +
"&password=XXXXXX" +
"&language= 3 Or 2 Or 1" +
"&sender=Your Sender " +
"&mobile=2012XXXXXX, 2011XXXX" +
"&message=Encoded Message" +
"&DelayUntil="+sendtime
).Result;
I am new to Flex and also new to writing a client for a web service.
My question is more about Flex (Flash Builder 4.5) APIs, what APIs to use.
I want to access a web service, and create a Flex / AIRwrapper for it,
which anyone can use.
Here is the spec of webservice.
I have to do a post on POST https://build.phonegap.com/api/v1/apps
content type has to be "multipart/form-data"
JSON bodies of requests are expected to have the name 'data' and will be something like this:
data={"title":"API V1 App","package":"com.alunny.apiv1","version":"0.1.0","create_method":"file"}
include a zip file in the multipart body of your post, with the parameter name 'file'.
I want to make a 'multipart/form-data' Post and send one string and one zip file.
My first question to self was if I send both string + binary data in the body,
how will server understand where string end and where zip file starts?
Then I read how text + binary data can be sent through "multipart/form-data" post request. There has to be some boundaries.
After this I read and example in flex and tried following it.
http://codeio.wordpress.com/2010/04/03/5-minutes-on-adobe-flex-mimic-file-upload-for-in-memory-contents/
but it doesn't seem to be working for me.
public function createNewApp(cb:Function , appFile : File):void
{
var service:HTTPService = new HTTPService();
service.url = ROOT+"apps";
service.showBusyCursor = true;
service.addEventListener(ResultEvent.RESULT, function(e:ResultEvent):void {
//translate JSON
trace(e.result);
var result:String = e.result.toString();
var data:Object = JSON.parse(result);
cb(data.link);
});
service.addEventListener(FaultEvent.FAULT, defaultFaultHandler); //todo : allow user to add his own as well
authAndUploadNewApp(service,appFile);
}
private function authAndUploadNewApp(service:HTTPService,appFile : File):void {
var encoder:Base64Encoder = new Base64Encoder();
encoder.encode(username + ":"+password);
service.headers = {Accept:"application/json", Authorization:"Basic " + encoder.toString()};
service.method ="POST";
var boundary:String = UIDUtil.createUID();
service.contentType = "multipart/form-data; boundary=—————————" + boundary;
var stream:FileStream = new FileStream();
stream.open(appFile, FileMode.READ);
var binaryData:ByteArray = new ByteArray();
var fileData : String = new String();
stream.readBytes(binaryData);
stream.close();
fileData = binaryData.readUTFBytes(binaryData.bytesAvailable); // I think this is where I have problem.... how do
//how do i converrt this bytearray/stream of data to string and send it in my post request's body - i guess if this step work rest should work..
var params: String = new String();
var content:String = "—————————" + boundary + "nr";
content += 'Content-Disposition: form-data; name="data";' + '{"title":"ELS test app 2","package":"com.elsapp.captivate","version":"12.3.09","create_method":"file"}' + "nr";
content += "—————————" + boundary + "nr";
content += 'Content-Disposition: form-data; name="file";' + fileData + "nr";
content += "—————————–" + boundary + "–nr";
service.request = content;
service.send();
}
I want to subscribe report on specific schedule in reporting services 2008. i.e report will dilever to user automatically on schedule. I am using visual studio 2008. I have done the configuration setting (rsreportserver.config, app.config after adding refrences of asmx files) by refrence msdn. The code is running fine (no exception occur) and I also get subscription id through calling create subscription indicate all going fine. But after running the code no entry made in Subscription table of ReportServer database. And also not get any mail. While through report server web tool, I can get email and also entery made in database but not from coe. Please someone help me. What I am missing. Plz help
Code is given follow: (Keep in mind, I am using VS2008)
void SendReportEmail()
{
RSServiceReference.ReportingService2005SoapClient rs=new RSServiceReference.ReportingService2005SoapClient();
rs.ClientCredentials.Windows.AllowedImpersonationLevel = new System.Security.Principal.TokenImpersonationLevel();
string batchID = string.Empty;
RSServiceReference.ServerInfoHeader infoHeader = rs.CreateBatch(out batchID);
BatchHeader bh = new BatchHeader()
{
BatchID = batchID,
AnyAttr = infoHeader.AnyAttr
};
string report = "/PCMSR6Reports/PaymentRequestStatusMIS";
string desc = "Send email from code to Hisham#comsoft.com";
string eventType = "TimedSubscription";
string scheduleXml="<ScheduleDefinition xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><StartDateTime xmlns=\"http://schemas.microsoft.com/sqlserver/2006/03/15/reporting/reportingservices\">2010-03-06T15:15:00.000+05:00</StartDateTime></ScheduleDefinition>";
RSServiceReference.ParameterValue[] extensionParams = new RSServiceReference.ParameterValue[7];
extensionParams[0] = new RSServiceReference.ParameterValue();
extensionParams[0].Name = "TO";
extensionParams[0].Value = "Hisham#comsoft.com";
extensionParams[1] = new RSServiceReference.ParameterValue();
extensionParams[1].Name = "IncludeReport";
extensionParams[1].Value = "True";
extensionParams[2] = new RSServiceReference.ParameterValue();
extensionParams[2].Name = "RenderFormat";
extensionParams[2].Value = "MHTML";
extensionParams[3] = new RSServiceReference.ParameterValue();
extensionParams[3].Name = "Subject";
extensionParams[3].Value = "#ReportName was executed at #ExecutionTime";
extensionParams[4] = new RSServiceReference.ParameterValue();
extensionParams[4].Name = "Comment";
extensionParams[4].Value = "Here is your test report for testing purpose";
extensionParams[5] = new RSServiceReference.ParameterValue();
extensionParams[5].Name = "IncludeLink";
extensionParams[5].Value = "True";
extensionParams[6] = new RSServiceReference.ParameterValue();
extensionParams[6].Name = "Priority";
extensionParams[6].Value = "NORMAL";
RSServiceReference.ParameterValue[] parameters = new RSServiceReference.ParameterValue[10];
parameters[0] = new RSServiceReference.ParameterValue();
parameters[0].Name = "BranchId";
parameters[0].Value = "1";
parameters[1] = new RSServiceReference.ParameterValue();
parameters[1].Name = "UserName";
parameters[1].Value = "admin";
parameters[2] = new RSServiceReference.ParameterValue();
parameters[2].Name = "SupplierId";
parameters[2].Value = "0";
string matchData = scheduleXml;
RSServiceReference.ExtensionSettings extSettings = new RSServiceReference.ExtensionSettings();
extSettings.ParameterValues = extensionParams;
extSettings.Extension = "Report Server Email";
try
{
string sub="";
RSServiceReference.ServerInfoHeader SubID = rs.CreateSubscription(bh, report, extSettings, desc, eventType, matchData, parameters, out sub);
rs.FireEvent(bh, "TimedSubscription", sub);
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
Detail response will be highly appricated.
Try adding # at the beginning of your xml string #"
I am working on a flex site,
I want to parse the string below:
http://virtual.s1.c7beta.com/rpc/raw?c=Pictures&m=download_picture&key=a4fb33241662c35fe0b46c7e40a5b416&session_id=2b7075f175f599b9390dd06f7b724ee7
and remove the &session_id=2b7075f175f599b9390dd06f7b724ee7 from it.
How should i do it.
also later on when i get the url from database without session_id, i will attach the new session_id to it. Please tell me how to do that too.
Regards
Zeeshan
Not the short version but you can use URLVariable to get all the field(name, value) into an object and then add or delete any field you want.
Separate url and query:
var url : String = "http://virtual.s1.c7beta.com/rpc/raw?c=Pictures&m=download%5Fpicture&key=a4fb33241662c35fe0b46c7e40a5b416&session%5Fid=2b7075f175f599b9390dd06f7b724ee7";
var idxQMark : int = url.indexOf("?");
var qry : String = "";
Build url variable from query
var uv : URLVariables = new URLVariables();
if (idxQMark > 0) {
qry = url.substr(idxQMark + 1);
url = url.substr(0, idxQMark);
uv.decode(qry);
}
NOw you can access whatever field you need or delete them
delete uv.session_id;
Rebuild the query when needed
qry = uv.toString();
// get back you new URL
if (qry != "") {
url = url + "?" + qry;
}
For URI parsing check out the URI class provided in as3corelib.
http://code.google.com/p/as3corelib/source/browse/trunk/src/com/adobe/net/URI.as
For your specific case, you can clear the parts of the URI you don't want.
var url : String = "http://virtual.s1.c7beta.com/rpc/raw?c=Pictures&m=download%5Fpicture&key=a4fb33241662c35fe0b46c7e40a5b416&session%5Fid=2b7075f175f599b9390dd06f7b724ee7";
var uri : URI = new URI(url);
uri.query = "";
uri.fragment = "";
var shortenedUrl : String = uri.toString();
Or if you know you want to construct your url from just the scheme, authority, and path (i.e., you don't need to preserve port, username, password, etc.) you can build the url from parts.
var shortenedUrl : String = uri.scheme + "://" + uri.authority + "/" + uri.path;
If you're not sure that sessionid will be last you could split on the & using the as3 string.split functionhttp://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/String.html#split%28%29
then rebuild the string using a for loop leaving out strings that start with session_id using the string.indexOf function http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/String.html#indexOf%28%29 to see if "session_id" is at index 0
You can use regular expressions in Flex ... here's an example.
Assuming the session ID will always be the last variable in the query string:
var newStr:String = myStr.slice(0, myStr.indexOf("&session"));