API_Defining an array - api

How can I define array below in Intellij? I am sending this API request and getting error:
sharedAccountDetails [
Account details.
SharedAccountItem{
accountNumber string
Account number of the user.
accountName string
Account name of the user.
accountType string
Account type saving/current etc.
branchCode string
Branch Code.
}]
This is my request below:
And request { 'channel': 'email'}
And request { 'accountNumber': '000000000'}
And request { 'accountName': 'Mr Bytes C'}
And request { 'accountType': 'Current Account'}
And request { 'branchCode': '000'}
It is requesting for the arrays. how do I define them?
Thanks in advance.
Regards,
Tshilidzi

Not sure I understand but can you look at the demo examples of Karate carefully. Looks like you have to understand how to use JSON. See this example below:
And request
"""
{
sharedAccountDetails: [
{ accountNumber: '000000000', 'accountName': 'Mr Bytes C', 'accountType': 'Current Account' }
]
}
"""

Related

Query Loopring NFTs using the GraphQL "Playground"

Hello and thanks in advance for any help.
I would like to write a simple query to find out Loopring NFT (non-fungible token) data using the Loopring subgraph, given a user account number. (Note the account number is the Loopring address, similar to an Ethereum address, a hexadecimal as string type)
The subgraph playground for Loopring is here: https://thegraph.com/explorer/subgraph?id=7QP7oCLbEAjejkp7wSLTD1zbRMSiDydAmALksBB5E6i1&view=Playground
Here is my code:
query accountNFTSlotsQuery(
$skip:Int
$first:Int
$orderBy: AccountNFTSlot_orderBy
$orderDirection:OrderDirection
$where:AccountNFTSlot_filter
) {
accountNFTSlots(
skip : 0
first: 100
orderBy: createdAt
orderDirection: asc
where: {
account: "0x08F06d44D6D3e35a3790392571194d86090C863539277"
}
) {
id
account {
id
}
balance
nft {
id
nftType
nftID
mintedAt
}
}
}
The playground is returning...
{
"data": {
"accountNFTSlots": []
}
}
Which I interpret as returning NULL, or "no data found". For the address above, one can verify NFTs exist using lexplorer:
https://lexplorer.io/account/39277
Variations:
I have tried several accounts which I know have NFTs.
I have tried replacing the "account" string with an "id" in the 'where' filter thus:
where: {
id: 39277
}
Model:
I used this github repo as a model for my queries: https://github.com/fudgebucket27/Lexplorer/blob/master/Shared/Services/LoopringGraphQLService.cs

JWS Error during API testing python flask

I am trying to test a function, which basically calls the API by passing a some values, which is then loaded to the schema to be validated and then accepted or rejected based on validation.
The below is my test function.
params = {
'first': [10,20],
'second': 400,
'third ': 'Testing'
}
headers = {
'Authorization': 'Bearer{}'.format(token),
'Data-type' : "json"
}
response = self.client.post(url_for('MyView:post', id=current_id.id),
json=params,
headers=headers)
This renders me the error below:
{
"msg": "Invalid header string: must be a json object"
}
I was able to check the issue and found out its due to the mapping of invalid types. But as headers is still a dictionary, I am not able to comprehend why this error is being rendered.
I have also added the structure of my schema and API below:
class MySchema(marshmallow.Schema):
id = fields.Integer(required=True)
second = fields.Integer(fields.Integer(), required=True)
first = fields.List(fields.String(), required=False)
third = fields.Str(validate=validate.Length(min=0, max=255), required=False)
class Meta:
fields = ('id',
'second',
'first',
'third')
#validates_schema(pass_original=True)
def validate_numbers(self, _, data):
//function code
The below is the structure of my API
class MyView(V1FlaskView):
#jwt_requried
def post(id):
//code
Maybe a space character is missing after Bearer:
'Authorization': 'Bearer {}'.format(token),

Unable to Post an invoice to Sage One via API 422 Error

I am able to authenticate against the SAGE ONE API and also able to retrieve data from the API however I am now trying to post a simple invoice however keep getting a 422 error. Is there something obvious I am missing?
I have double checked the JSON structure and the values i am providing and are all valid. Not sure what i am doing wrong here!
my JSON package looks like this
{"contact_id":"66b76fa19edc11e797950a57719b2edb",
"date":"2019-04-13",
"invoice_lines":[{"description":"Test Description",
"ledger_account_id":"0367afd89ece11e797950a57719b2edb","quantity":1,"unit_price":100}]}
code
Dim http As HttpWebRequest = WebRequest.Create(New Uri("https://api.columbus.sage.com/uki/sageone/accounts/v3/sales_invoices"))
http.Method = "POST"
http.ContentType = "application/json"
http.Accept = "application/json"
http.Headers.Add("X-Site", "mysite")
http.Headers.Add("ocp-apim-subscription-key", "mykey")
http.Headers.Add("Authorization", "Bearer " mytoken)
Dim data = Encoding.UTF8.GetBytes(json)
http.ContentLength = data.Length
Dim stream = http.GetRequestStream()
stream.Write(data, 0, data.Length)
stream.Close()
Dim response = http.GetResponse().GetResponseStream()
This POST body worked for me (with different ids):
{
"sales_invoice": {
"contact_id": "66b76fa19edc11e797950a57719b2edb",
"date": "2019-04-13",
"main_address": { "address_line_1": "42 Test Street" },
"invoice_lines": [
{
"description": "Test Description",
"ledger_account_id": "0367afd89ece11e797950a57719b2edb",
"quantity": 1,
"unit_price": 100,
"tax_rate_id": "GB_NO_TAX"
}
]
}
}
You need to wrap your JSON structure with a key, which is the name of your resource ("sales_invoice" in this case).
You also need to specify a main address, as well as a tax rate id for each line item.
To be sure to have a valid ledger account for your sales invoice, get a list of possible accounts with:
GET /ledger_accounts?visible_in=sales

Replica volume id unable to retrieve

I was trying to retrieve replica volume id using filter & softlayer services, but filter does not work.
objectFilterstorage = {"iscsiNetworkStorage": {"username": {"operation": storage_name}}}
client [Softlayer_Account].getIscsiNetworkStorage(filter=objectFilterstorage)
Here, I need help to get the object filter.
Please, try the following using SoftLayer_Account::getNetworkStorage:
https://[username]:[apikey]#api.softlayer.com/rest/v3/SoftLayer_Account/getNetworkStorage?objectMask=mask[id,username,replicationPartners[id,username]]&objectFilter={ "networkStorage": { "replicationPartners": { "username": { "operation": "MYUSERNAME_REP_1" } } } }
Method:GET

Is there a specific scope that I can use WL.Server.SetActiveUser?

I am trying to create an adapter based authentication in Worklight. I have added my Realm, Security test, and Login Module to the authenticationConfig file. I have tried to follow along with the modules provided by IBM. I've copied the exact syntax and even hard coded values for the WL.Server.setActiveUser method. But I continue to get an error. Is there a certain scope I can use this method in? Does anyone see or know where my error is?
I continue to get the follow error:
LOG: Request [login]
LOG: Request [/apps/services/api/GPC2/android/query]
LOG: response [/apps/services/api/GPC2/android/query] success: /*-secure-
{"responseID":"1","isSuccessful":true,"resultSet REMOVED LINE THAT CONTAINED DB RESULTS FOR SECURITY
[/apps/services/api/GPC2/android/query] exception.
SCRIPT5007: Unable to get value of the property 'setActiveUser': object is null or undefined
var lname= responseData.invocationResult.resultSet[0].somelastname;
var gpcid = responseData.invocationResult.resultSet[0].someid;
var fname = responseData.invocationResult.resultSet[0].somefname;
WL.Logger.debug("Login :: SUCCESS" + lname + " " + gpcid + " " + fname); //this line does write the values to the log
//WL.Client.login("NotificationsRealm");
WL.Server.setActiveUser ("NotificationsRealm", {
userId: gpcid,
displayName: fname,
attributes: {
firstName: fname,
lastName : lname,
isUserAuthenticated: 1,
}
});
Looking at the API documentation for WL.Server.setActiveUser, it should be like this:
WL.Server.setActiveUser ("ACMERealm", {
userId: "38017840288",
displayName: "John Doe",
attributes: {
"firstName": "John",
"lastName": "Doe",
"lastLogin": "2010-07-13 19:25:08.0 GMT",
}
})
Looks like you are missing the double quotes for the attributes?