We are tring to automate user creation using perl and json. I have this error on the PUT command:
<h1>Method Not Allowed</h1>
<p>The requested method PUT is not allowed for the URL /https://sandbox.rallydev.com/slm/webservice/1.43/user/create.js.</p>
</body></html>
',
'_rc' => '405',
Attempting POST gives me this:
<h1>Not Found</h1>
<p>The requested URL /https://sandbox.rallydev.com/slm/webservice/1.43/user/create.js was not found on this server.</p>
</body></html>
',
'_rc' => '404',
Is there an example of creating a Rally user with perl?
Here is a basic example in Perl showing how to create a Rally user. Requires the following Perl modules:
REST::Client
JSON
MIME::Base64
I tested this using v5.14.2 on Ubuntu 12.04.
use strict;
use warnings;
# Needed includes
use REST::Client;
use JSON;
use MIME::Base64;
use URI;
use URI::Split;
# User parameters
# Must be a Rally Subscription Administrator, or a Workspace Administrator
# in a Rally Workspace whose Workspace Admins have been granted user administration
# privileges
my $username='user#company.com';
my $password='topsecret';
# Rally connection parameters
my $base_url="https://rally1.rallydev.com";
my $wsapi_version = "1.43";
# Connect to Rally and create user
# ====================================
my $headers = {
Accept => 'application/json',
Authorization => 'Basic ' . encode_base64($username . ':' . $password)
};
# instantiate REST Client
my $rest_client = REST::Client->new();
# set host
$rest_client->setHost($base_url);
# Formulate POST request to create user
# Note that the a Rally User must have at least one Workspace Permission / Project Permission
# pair. Thus the user will be given User Permissions in the Default Workspace of the
# Subscription or Workspace Administrator whose RallyID is used to run this script.
# The user will receive Viewer-level permissions to the alphabetically
# First project in the Default Workspace of the Rally UserID used to run the script
my $new_rally_user_id = 'user12#company.com';
print "Connecting to Rally and attempting to create user of UserID: \n";
print $new_rally_user_id . "\n\n";
my $wsapi_endpoint = "/slm/webservice/" . $wsapi_version . "/";
my $user_create_endpoint = $wsapi_endpoint . "user/create.js";
my $user_post_body = '{"User": {"UserName": "' . $new_rally_user_id . '", "EmailAddress": "' . $new_rally_user_id . '"}}';
print "POST Body for user creation:\n";
print $user_post_body . "\n\n";
# Attempt Create
$rest_client->POST($user_create_endpoint, $user_post_body, $headers);
# Output JSON Response
print "Create Response:\n\n";
print $rest_client->responseContent();
Here's the outcome of running the script:
$ perl rally_create_user.pl
Connecting to Rally and attempting to create user of UserID:
user12#company.com
POST Body for user creation:
{"User": {"UserName": "user12#company.com", "EmailAddress": "user12#company.com"}}
Create Response:
{ "CreateResult" : { "Errors" : [ ],
"Object" : { "Boolean" : null,
"CUF" : null,
"CostCenter" : "None",
"CreationDate" : "2013-07-11T22:49:00.056Z",
"Date" : null,
"Department" : "None",
"Disabled" : false,
"DisplayName" : null,
"Editable" : null,
"EmailAddress" : "user12#company.com",
"FirstName" : null,
"LandingPage" : "/dashboard",
"LastLoginDate" : null,
"LastName" : null,
"LastPasswordUpdateDate" : "2013-07-11T22:49:00.056Z",
"MiddleName" : null,
"NetworkID" : null,
"ObjectID" : 12345678913,
"OfficeLocation" : "None",
"OnpremLdapUsername" : null,
"Phone" : null,
"RevisionHistory" : { "_rallyAPIMajor" : "1",
"_rallyAPIMinor" : "43",
"_ref" : "https://rally1.rallydev.com/slm/webservice/1.43/revisionhistory/12345678915.js",
"_type" : "RevisionHistory"
},
"Role" : "None",
"ShortDisplayName" : null,
"Specialty" : null,
"String" : null,
"Subscription" : { "_rallyAPIMajor" : "1",
"_rallyAPIMinor" : "43",
"_ref" : "https://rally1.rallydev.com/slm/webservice/1.43/subscription/12345678914.js",
"_refObjectName" : "My Subscription",
"_type" : "Subscription"
},
"SubscriptionAdmin" : false,
"TeamMemberships" : [ ],
"Text" : null,
"UserName" : "user12#company.com",
"UserPermissions" : [ { "_rallyAPIMajor" : "1",
"_rallyAPIMinor" : "43",
"_ref" : "https://rally1.rallydev.com/slm/webservice/1.43/workspacepermission/12345678917u12345678918w3.js",
"_refObjectName" : "My Workspace User",
"_type" : "WorkspacePermission"
},
{ "_rallyAPIMajor" : "1",
"_rallyAPIMinor" : "43",
"_ref" : "https://rally1.rallydev.com/slm/webservice/1.43/projectpermission/12345678919u12345678920p1.js",
"_refObjectName" : "A Project",
"_type" : "ProjectPermission"
}
],
"UserProfile" : { "_rallyAPIMajor" : "1",
"_rallyAPIMinor" : "43",
"_ref" : "https://rally1.rallydev.com/slm/webservice/1.43/userprofile/12345678921.js",
"_type" : "UserProfile"
},
"_CreatedAt" : "just now",
"_objectVersion" : "2",
"_rallyAPIMajor" : "1",
"_rallyAPIMinor" : "43",
"_ref" : "https://rally1.rallydev.com/slm/webservice/1.43/user/12345678922.js",
"_refObjectName" : "user12",
"_type" : "User",
"yesno" : null
},
"Warnings" : [ "API status is Deprecated and will become Not Supported on 2014-Jun-20" ],
"_rallyAPIMajor" : "1",
"_rallyAPIMinor" : "43"
You start your URI and its https scheme mistakenly with a /. Remove it.
Related
I'd like to create a Customer in acumatica using REST API. I imported into postman official JSON swagger config and I'm using following endpoint:
http://*********/Acumatica2019DB/entity/Default/17.200.001/Customer
Method: PUT
Body:
{
"CustomerID" : {"value" : "JOHNGOOD" } ,
"CustomerName" : {"value" : "John Good" },
"MainContact" :
{
"Email" : {"value" : "demo#gmail.com" },
"Address" :
{
"AddressLine1" : {"value" : "4030 Lake Washington Blvd NE" },
"AddressLine2" : {"value" : "Suite 100" },
"City" : {"value" : "Kirkland" },
"State" : {"value" : "WA" },
"PostalCode" : {"value" : "98033" }
}
}
}
I'm facing following issue:
Error: An error occurred during processing of the field Subaccount: Error: Product Group, Department of Subaccount do not exist in the system.
---> PX.Data.PXSetPropertyException: Error: Product Group, Department of SubCD do not exist in the system.
What do these values (Product Group, Department of Subaccount) mean? How can I configure them?
I have a MongoDB query based in Objects as "Ticket" structure, each ticket usually contains Tasks Object and each of them have an Owner, if the Ticket is Open, the associate Owner is “OpnPrps.CurAgtNme”, by other hand if the ticket is Closed, the associate Owner is “Nms.CloAgt”.
This is how my database (JSON) look like:
{
"result" : [
{
"_id" : NumberLong(3131032306336),
"TicId" : 1147552,
"OrgId" : 729,
"Sts" : "Closed",
"CrtDat" : ISODate("2015-04-23T18:50:46.000Z"),
"CloDat" : ISODate("2015-04-23T19:46:26.000Z"),
"ShtDes" : "Copy of Employment agreement",
"Des" : "EE wants a copy of employment agreement. address was verified.",
"DesSum" : "EE wants a copy of employment agreement. address was verified.",
"Sol" : "ISIGHT TICKET NUMBER:<br><h1>US-04-15-01109</h1>",
"CrtAgtId" : 20444,
"CloAgtId" : 20149,
"CrtApp" : null,
"IsInt" : false,
"HasPrtTsk" : null,
"PexBodId" : "",
"PayGrp" : "",
"RvwDat" : null,
"RclDat" : null,
"IsDynDueDatDef" : false,
"OlaDat" : ISODate("2015-04-25T00:50:50.000Z"),
"SlaDat" : ISODate("2015-04-25T00:50:50.000Z"),
"DynDueDatElaDat" : null,
"ReaTim" : "00:00:00",
"LstUpd" : ISODate("2015-04-23T19:46:26.000Z"),
"VrsOnl" : 2,
"VrsArc" : 1,
"OpnPrps" : null,
"Nms" : {
"Cmp" : "Organization1 US",
"Org" : "Organization1",
"Srv" : "Policies",
"SrvGrp" : "17. Workforce Administration (NGR)",
"Wkg" : "WORKGROUP1",
"Pri" : "",
"Tir" : "T1",
"Src" : "Call",
"CrtAgt" : "Arun ",
"CloAgt" : "Felicia"
},
"Olas" : {
"_id" : 2,
"EntNam" : "ENTITY",
"DueDat" : ISODate("2015-04-25T00:50:50.000Z"),
"AmbDat" : ISODate("2015-04-24T20:50:49.000Z"),
"DueDatElaDat" : null,
"AmbDatElaDat" : null,
"SlaDuration" : 18,
"TotTim" : NumberLong(0),
"TotTimPndEnt" : NumberLong(0),
"TotTimPndEmp" : NumberLong(0),
"RclInSla" : false
},
"Tsks" : {
"_id" : 1,
"Typ" : "Planned",
"CrtDat" : ISODate("2015-04-23T18:50:46.000Z"),
"CloDat" : null,
"LstUpd" : ISODate("2015-04-23T18:50:46.000Z"),
"DueDat" : ISODate("2015-04-25T00:50:50.000Z"),
"TimCplTsk" : 1080,
"DueDatEla" : false,
"AgtOwnId" : null,
"WkgSklId" : 45387,
"EntId" : 2,
"Sts" : "Open",
"PrdTskId" : 201,
"Ttl" : "Provide Navigational Assistance",
"Des" : "Provide Navigational Assistance",
"SrvSklId" : 45792,
"PriSklId" : null,
"TotTim" : 0,
"PtnId" : null,
"PtnTic" : null,
"DepTskId" : null,
"IsAct" : true,
"IsMndOnCloTic" : false,
"Nms" : {
"AgtOwn" : null,
"Wkg" : "CM_T1",
"Ent" : "ENTITY",
"SrvSkl" : "Policies",
"PriSkl" : null,
"Ptn" : null,
"Frm" : ""
},
"AscTicItm" : null,
"FrmId" : null,
"Flds" : []
},
And the query I'm using to group the data looks like:
db.tickets.aggregate([
{$match:{
'Nms.Org': 'Organization1',
'Nms.Cmp':'Company',
'Nms.Wkg':'Workgroup’
}},
{$project:{
_id:0,
'Tsks._id':1,
'Tsks.Sts':1,
'Tsks.DueDat':1,
'Sts':1,
'Nms.Org':1,
'Nms.Cmp':1,
'Nms.Wkg':1,
'Nms.CloAgt':1,
'OpnPrps.CurAgtNme':1,
'OpnPrps.CurEntNme':1,
'Olas.EntNam':1
}},
{$unwind : "$Olas" },
{$unwind : "$Tsks" },
{$match:{$and:[{
'Tsks.DueDat': {$ne: null},
'Olas.EntNam': 'Entity',
'Tsks._id':{$gt:0}
}]}},
{$group:
{_id:{
Org:'$Nms.Org',
Cmp:'$Nms.Cmp',
Wkg:'$Nms.Wkg',
CurEntNme:'$Olas.EntNam',
CurTskId: '$Tsks._id',
DueDate:'$Tsks.DueDat',
Owner1:'$OpnPrps.CurAgtNme',
Owner2:'$Nms.CloAgt'
},
All: {$sum: { $cond:
[
{ $eq: [ '$Tsks.DueDat' , null ] } ,0,1
]}}
},
}
])
With this query I’m able to get every ticket for every owner (even if they’re open or closed) and their associate tasks, my problem is that I want to group all the tickets without taking in consideration the status, something like a second group after the results I have now, see below:
The table I get with Jasper Studio with this query looks like:
Owner Inventory
--------- --------------
Noemi 1 Owner1:Noemi | Owner2:null
Carl 2 Owner1:null | Owner2:Carl
Darla 2 Owner1:Darla| Owner2:null
Carl 1 Owner1:Carl| Owner2:null
Paola 2 Owner1:null| Owner2:Paola
Noemi 2 Owner1:null | Owner2:Noemi
As you can see, I’m getting repeated values due to the different field from each ticket. The table I'm looking for should be like this:
Owner Inventory
--------- --------------
Noemi 3 Owner1:Noemi | Owner2:Noemi
Carl 3 Owner1:Carl | Owner2:Carl
Darla 2 Owner1:Darla| Owner2:null
Paola 2 Owner1:null| Owner2:Paola
So, my problem is that I can’t find the way to group these results again to obtain the second table.
Could you help me to resolved the problem that I have?
Using Postman (REST Client - chrome extension) I do a Post to a REST service an I get the correct answer from the services.
The answer is "201 Created" and a new row is added into the DB.
URL = http://suring-t.suremptec.com.ar/gis/13/rest/1.0/organizations
form-date = metadata
{
"meta" : {
"version" : "1.0",
"description" : "Organization"
},
"id" : null,
"name" : "test org",
"startDate" : "2014-06-05 16:20:31.334",
"endDate" : null,
"administrable" : true,
"published" : true,
"href" : "\/2\/rest\/1.0\/organizations\/1"
}
I can't find the way to make SoapUI (5.1.2) works with the same request.
URL = http://suring-t.suremptec.com.ar/gis/13/rest/1.0/organizations
form-date =
metadata
{
"meta" : {
"version" : "1.0",
"description" : "Organization"
},
"id" : null,
"name" : "test org",
"startDate" : "2014-06-05 16:20:31.334",
"endDate" : null,
"administrable" : true,
"published" : true,
"href" : "/2/rest/1.0/organizations/1"
}
The response is "200 - Ok" but
Any Ideas, how should configure the soapui request?
This should get you started Getting started with REST
I'm using groovy with mongodb. I have a result set but need a value from a different grouping of documents. How do I pull that value into the result set I need?
MAIN:Network data
"resource_metadata" : {
"name" : "tapd2e75adf-71",
"parameters" : { },
"fref" : null,
"instance_id" : "9f170531-79d0-48ee-b0f7-9bd2788b1cc5"}
I need the display_name for the network data result set which is contained in the compute data.
CPU data
"resource_id" : "9f170531-79d0-48ee-b0f7-9bd2788b1cc5",
"resource_metadata" : {
"ramdisk_id" : "",
"display_name" : "testinstance0001"}
You can see the resource_id and the Instance_id are the same values. I know there is no relationship I can do but trying to reach to see if anyone has come across this. I'm using the table model to retrieve data for reporting. Hashtable has been suggested to me but I'm not seeing that working. Somehow in the hasNext I need to include the display_name value. in the networking data so GUID number doesn't only valid name shows from compute data.
def docs = meter.find(query).sort(sort).limit(50)\
while (docs.hasNext()) { def doc = docs.next()\
model.addRow([ doc.get("counter_name"),doc.get("counter_volume"),doc.get("timestamp"),\
doc.get("resource_metadata").getString("mac"),\
doc.get("resource_metadata").getString("instance_id"),\
doc.get("counter_unit")]
as Object[]);}
Full document:
1st set where I need the network data measure with no name only id {resource_metadata.instance_id}
{
"_id" : ObjectId("528812f8be09a32281e137d0"),
"counter_name" : "network.outgoing.packets",
"user_id" : "4d4e43ec79c5497491b23b13644c2a3b",
"timestamp" : ISODate("2013-11-17T00:51:00Z"),
"resource_metadata" : {
"name" : "tap6baab24e-8f",
"parameters" : { },
"fref" : null,
"instance_id" : "a8727a1d-4661-4565-9c0a-511279024a97",
"instance_type" : "50",
"mac" : "fa:16:3e:a3:bf:fc"
},
"source" : "openstack",
"counter_unit" : "packet",
"counter_volume" : 4611911,
"project_id" : "97dc4ca962b040608e7e707dd03f2574",
"message_id" : "54039238-4f22-11e3-8e68-e4115b99a59d",
"counter_type" : "cumulative"
}
2nd set where I want to grab the name as I get the values {resource_id}:
"_id" : ObjectId("5287bc3ebe09a32281dd2594"),
"counter_name" : "cpu",
"user_id" : "4d4e43ec79c5497491b23b13644c2a3b",
"message_signature" :
"timestamp" : ISODate("2013-11-16T18:40:58Z"),
"resource_id" : "a8727a1d-4661-4565-9c0a-511279024a97",
"resource_metadata" : {
"ramdisk_id" : "",
"display_name" : "vmsapng01",
"name" : "instance-000014d4",
"disk_gb" : "",
"availability_zone" : "",
"kernel_id" : "",
"ephemeral_gb" : "",
"host" : "3746d148a76f4e1a8203d7e2378ef48ccad8a714a47e7481ab37bcb6",
"memory_mb" : "",
"instance_type" : "50",
"vcpus" : "",
"root_gb" : "",
"image_ref" : "869be2c0-9480-4239-97ad-df383c6d09bf",
"architecture" : "",
"os_type" : "",
"reservation_id" : ""
},
"source" : "openstack",
"counter_unit" : "ns",
"counter_volume" : NumberLong("724574640000000"),
"project_id" : "97dc4ca962b040608e7e707dd03f2574",
"message_id" : "a240fa5a-4eee-11e3-8e68-e4115b99a59d",
"counter_type" : "cumulative"
}
This is another collection that contains the same value but just thought it would be easier to grab from same collection:
"_id" : "a8727a1d-4661-4565-9c0a-511279024a97",
"metadata" : {
"ramdisk_id" : "",
"display_name" : "vmsapng01",
"name" : "instance-000014d4",
"disk_gb" : "",
"availability_zone" : "",
"kernel_id" : "",
"ephemeral_gb" : "",
"host" : "3746d148a76f4e1a8203d7e2378ef48ccad8a714a47e7481ab37bcb6",
"memory_mb" : "",
"instance_type" : "50",
"vcpus" : "",
"root_gb" : "",
"image_ref" : "869be2c0-9480-4239-97ad-df383c6d09bf",
"architecture" : "",
"os_type" : "",
"reservation_id" : "",
}
Mike
It looks like these data are in 2 different collections, is this correct?
Would you be able to query CPU data for each "instance_id" ("resource_id")?
Or if this would cause too many queries to the database (looks like you limit to 50...) you could use $in with the list of all "Instance_id"s
http://docs.mongodb.org/manual/reference/operator/query/in/
Either way, you will need to query each collection separately.
My application has both facebook and twitter users. Now users can merge two accounts together which means they can login with either facebook or twitter account.
Right now, I have a model like this.
{ "_id" : ObjectId("51103a3e69931d2f03000001"), "email" : "email", "id" : "twitter_id", "token" : "token", "secret" : "secret"}
{ "_id" : ObjectId("51103a3e69931d2f03000001"), "email" : "email", "id" : "facebook_id", "token" : "token", "secret" : ""}
Now if these two accounts are the same and the user decided to merge or connect one of his account to something else. How should I change this model effectively and performance as well. I am thinking of having another object called
{"linked_ids" : ["facebook_id", "linkedin_id" ]}
in both accounts. So, the data would be like this. Once merged.
{ "_id" : ObjectId("51103a3e69931d2f03000001"), "email" : "email", "id" : "twitter_id", "token" : "token", "secret" : "secret", "linked_id" : ["facebook_id"] }
{ "_id" : ObjectId("51103a3e69931d2f03000001"), "email" : "email", "id" : "facebook_id", "token" : "token", "secret" : "", "linked_id" : ["twitter_id"] }
Not sure if this would be the best way for performance and scalability?
Why not have one user document in a user collection from the start? You could model it this way instead:
{
"_id" : ObjectId("..."),
"username" : "bob123",
"accounts" : [
{
"email": "email",
"id": "twitter_id",
"token": "token",
"secret": "secret",
"type" : "Twitter"
},
{
"email": "email",
"id": "facebook_id",
"token": "token",
"secret": "",
"type" : "Facebook"
}
]
}
Mongo has plenty of operations to deal with arrays. You can add to them, update one item in the array only, etc.
Doing joins with Mongo introduces complexity that it isn't good at handling as of now. You'd have to do that "join" in your application.
Also this model means you can add any other forms of authentication in one document.