i am working with authorized .net in ios
The mobile device is approved fine but i am getting the following error in "createTransaction" even i am not sending ant transaction key also
Create Transaction response
2012-07-26 18:23:40.600 Authorized[2095:207] <?xml version="1.0" encoding="utf-8"?><ErrorResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"><messages><resultCode>Error</resultCode><message><code>E00003</code><text>The element 'merchantAuthentication' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has incomplete content. List of possible elements expected: 'name, transactionKey, sessionToken, password' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'.</text></message></messages></ErrorResponse>
namespace warning : xmlns: URI AnetApi/xml/v1/schema/AnetApiSchema.xsd is not absolute
ttp://www.w3.org/2001/XMLSchema" xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"
^
2012-07-26 18:23:40.601 Authorized[2095:207] Error = (null)
2012-07-26 18:23:40.601 Authorized[2095:207] Message:
Message.code = E00003
Message.text = The element 'merchantAuthentication' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has incomplete content. List of possible elements expected: 'name, transactionKey, sessionToken, password' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'.
Message.description = (null)
2012-07-26 18:23:40.601 Authorized[2095:207] Messages:
Messages.resultCode = Error
Messages.message = (
"Message.code = E00003\nMessage.text = The element 'merchantAuthentication' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has incomplete content. List of possible elements expected: 'name, transactionKey, sessionToken, password' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'.\nMessage.description = (null)\n"
)
2012-07-26 18:23:40.635 Authorized[2095:207] Messages:
Messages.resultCode = (null)
Messages.message = (
)
2012-07-26 18:23:40.636 Authorized[2095:207] SplitTenderPayment = SplitTenderPayment.transId = (null)
SplitTenderPayment.responseCode = (null)
SplitTenderPayment.responseToCustomer = (null)
SplitTenderPayment.authCode = (null)
SplitTenderPayment.accountNumber = (null)
SplitTenderPayment.accountType = (null)
SplitTenderPayment.requestedAmount = (null)
SplitTenderPayment.approvedAmount = (null)
SplitTenderPayment.balanceOnCard = (null)
2012-07-26 18:23:40.637 Authorized[2095:207] CreateTransactionResponse: createTransactionResponse.anetAPIResponse = ANetApiResponse.refId = (null)
ANetApiResponse.messages = Messages.resultCode = Error
Messages.message = (
"Message.code = E00003\nMessage.text = The element 'merchantAuthentication' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has incomplete content. List of possible elements expected: 'name, transactionKey, sessionToken, password' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'.\nMessage.description = (null)\n"
)
as Sandchitsignh points out, this looks like you are processing a response, that are not a fully valid xml response. Check the response thoroughly, and make sure no hidden, corrupt or unescaped characters have snuck their way in.
Related
I want to change Yahoo ads conversion tracker name through API automatically.
But, when I run the following code, that returned an error.
access_token = XXXXXXXXXXXXX
account_id = XXXXXX
conversion_id = XXXXXXX
new_name = "new_name"
header = {"Content-Type": "application/json",\
"Accept": "application/json",\
"Authorization": "Bearer " + access_token}
url = "https://ads-search.yahooapis.jp/api/v8/ConversionTrackerService/set"
data = {'accountId':account_id, 'operand':[{'accountId': account_id, 'conversionTrackerId': conversion_id, "conversionTrackerName": new_name}]}
data = json.dumps(data).encode()
req = urllib.request.Request(url, data=data, method='POST', headers=header)
try:
with urllib.request.urlopen(req) as response:
body = json.loads(response.read())
headers = response.getheaders()
status = response.getcode()
print(headers)
print(status)
print(body)
except urllib.error.URLError as e:
print(e.reason)`
Retuened error is:
{'errors': [{'code': 'L0001', 'message': 'Lower list size.', 'details': [{'requestKey': 'operand', 'requestValue': None}]}], 'rid': '6fab0e1ac60dd2a871831484791976bf', 'rval': None}
I guess the length of "operand" field is 1 and it is right length according to yahoo api document. What I shuold do to fix this error?
I tryied to make length of "operand" field 2. But the result was same.
when i attempt to run following :
from authlib.integrations.requests_client import OAuth2Session
APPCLIENTID=os.getenv('AppClientId')
APPCLIENTSECRET=os.getenv('AppClientSecret')
USERNAME2=os.getenv("Username2")
PASSWORD2=os.getenv("Password222")
scope = 'openid email profile'
token_endpoint = 'https://api-product-test99.auth.eu-west-1.amazoncognito.com/oauth/token'
client = OAuth2Session(APPCLIENTID, APPCLIENTSECRET, scope=scope) #, redirect_uri="https://localhost/callback"
ar = 'https://localhost/callback?code=xxxxxx&state=xxxxx'
token = client.fetch_token(token_endpoint, authorization_response=ar)
print(token)
i get the message :
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
im just following the example on the Authlib page.
Am I missing something ?
I want to print attribute value from response if my assertion fails. Sample error Response:
<soapenv:Body>
<ns0:Fault xmlns:ns1="http://www.w3.org/2003/05/soap-envelope" xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/">
<faultcode>OSB-382500</faultcode>
<faultstring>Mandatory Parameter Customer Type cannot be empty (uuid: 1f8b9637-11b1-47ea-9ebd-3abf2fda950e)</faultstring>
<detail>
<ns0:Fault xmlns:ns0="http://group.vodafone.com/contract/vfo/fault/v1" xmlns:ns2="http://group.vodafone.com/contract/vho/header/v1" xmlns:ns3="http://group.vodafone.com/schema/common/v1" xmlns:ns6="http://docs.oasis-open.org/wsrf/bf-2" xmlns:ns7="http://www.w3.org/2005/08/addressing">
<ns6:Timestamp>2017-08-16T20:44:27.15+05:30</ns6:Timestamp>
<ns6:ErrorCode>500</ns6:ErrorCode>
<ns0:Name/>
<ns0:Severity>Critical</ns0:Severity>
<ns0:Category>Technical</ns0:Category>
<ns0:ReasonCode>ReasonCode</ns0:ReasonCode>
<ns0:Message>Service Callout Failure</ns0:Message>
</ns0:Fault>
</detail>
</ns0:Fault>
</soapenv:Body>
I want to print value "Service Callout Failure" if my assertion fails.
Currently my script is printing assertion status and testcase name. I want to print the particular attribute value from response. My Teardown Script:
import com.eviware.soapui.model.testsuite.Assertable.AssertionStatus
import jxl.*;
import jxl.write.*;
def TestCase = testRunner.getTestCase()
def StepList = TestCase.getTestStepList()
def status
def i = 0
WritableWorkbook workbook1 = Workbook.createWorkbook(new File("C:\\report1.xls"));
WritableSheet sheet1 = workbook1.createSheet("Report Worksheet", 0);
StepList.each{
if(it.metaClass.hasProperty(it,'assertionStatus')){
if(it.assertionStatus == AssertionStatus.FAILED){
log.info "${it.name} FAIL..."
status = "FAIL";
}else if(it.assertionStatus == AssertionStatus.VALID){
log.info "${it.name} OK!"
status = "Passed";
}else if(it.assertionStatus == AssertionStatus.UNKNOWN){
log.info "${it.name} UNKNOWN (PROBABLY NOT EXECUTED)"
status = "UNKNOWN";
}
}
Label label1 = new Label(i, sheet1.rows, it.name);
Label label2 = new Label(i+1, sheet1.rows, status);
sheet1.addCell(label1);
sheet1.addCell(label2);
}
workbook1.write();
workbook1.close();
I am using context.expand to get data from response to groovy,
for example
def hotel = context.expand( '${SearchHotels#Response#declare namespace ns1=\'someNamespace\'; declare namespace ns2=\'someNamespace2\'; //ns2:SearchHotelsResponse[1]/ns2:SearchHotelsResult[1]/ns1:TWS_HotelList[1]/ns1:Hotel[1]}' )
Namespace aside, at SearchHotels#Response... SearchHotels is name of test step, you can get response message using correct path to ns0:Message and then print it instead of constant data...
I used the below statement:
def req = it.name; message[k] = context.expand('${'+req+'#Response#declare namespace ns0=\'http://group.vodafone.com/contract/vfo/fault/v1\'; //ns0:Message}')
and it worked.
I am attempting to access the betfair API using Matlab and the urlread2 function available here.
EDIT: I have posted this problem on Freelancer if anyone can help with it: tinyurl.../pa7sblb
The documentation for the betfair API I am following is this getting started guide. I have successfully logged in and kept the session open using these codes: (I am getting a success response)
%% Login and get Token
url = 'https://identitysso.betfair.com/api/login';
params = {'username' '******' 'password' '******'};
header1 = http_createHeader('X-Application','*****');
header2 = http_createHeader('Accept','application/json');
header = [header1, header2];
[paramString] = http_paramsToString(params)
[login,extras] = urlread2(url,'POST',paramString,header)
login = loadjson(login)
token = login.token
%% Keep Alive
disp('Keep Session Alive')
url_alive = 'https://identitysso.betfair.com/api/keepAlive';
header1 = http_createHeader('X-Application','******');
header2 = http_createHeader('Accept','application/json');
header3 = http_createHeader('X-Authentication',token');
header_alive = [header1, header2, header3];
[keep_alive,extras] = urlread2(url_alive,'POST',[],header_alive);
keep_alive = loadjson(keep_alive);
keep_alive_status = keep_alive.status
My trouble starts when I am attempting to do the next step and load all available markets. I am trying to replicate this example code which is designed for Python
import requests
import json
endpoint = "https://api.betfair.com/exchange/betting/rest/v1.0/"
header = { 'X-Application' : 'APP_KEY_HERE', 'X-Authentication' : 'SESSION_TOKEN_HERE' ,'content-type' : 'application/json' }
json_req='{"filter":{ }}'
url = endpoint + "listEventTypes/"
response = requests.post(url, data=json_req, headers=header)
The code I am using for Matlab is below.
%% Get Markets
url = 'https://api.betfair.com/exchange/betting/rest/v1.0/listEventTypes/';
header_application = http_createHeader('X-Application','******');
header_authentication = http_createHeader('X-Authentication',token');
header_content = http_createHeader('content_type','application/json');
header_list = [header_application, header_authentication, header_content];
json_body = savejson('','filter: {}');
[list,extras] = urlread2(url_list,'POST',json_body,header_list)
I am having trouble with a http response code 415. I believe that the server cannot understand my parameter since the headings I have used with success previously.
Any help or advice would be greatly appreciated!
This is the error:
Response stream is undefined
below is a Java Error dump (truncated):
Error using urlread2 (line 217)
Java exception occurred:
java.io.IOException: Server returned HTTP response code: 415 for URL....
I looked at your problem and it seems to be caused by two things:
1) The content type should be expressed as 'content-type' and not 'content_type'
2) The savejson-function doesn't create an adequate json-string. If you use the json-request from the Python-script it works.
This code work for me:
%% Get Markets
url = 'https://api.betfair.com/exchange/betting/rest/v1.0/listEventTypes/';
header_application = http_createHeader('X-Application','*********');
header_authentication = http_createHeader('X-Authentication',token');
header_content = http_createHeader('content-type','application/json');
header_list = [header_application, header_authentication, header_content];
json_body = '{"filter":{ }}';
[list,extras] = urlread2(url,'POST',json_body,header_list)
i am working with authorized .net payement gateway in ios
In the following method
(void) createTransaction {
AuthNet *an = [AuthNet getInstance];
[an setDelegate:self];
CreditCardType *creditCardType = [CreditCardType creditCardType];
creditCardType.cardNumber = #"4111111111111111";
NSLog(#"babul cardNumber is %#",creditCardType.cardNumber);
creditCardType.cardCode = #"100";
NSLog(#"babul cardCode is %#",creditCardType.cardCode);
creditCardType.expirationDate = #"1212";
NSLog(#"babul expirationDate is %#",creditCardType.expirationDate);
PaymentType *paymentType = [PaymentType paymentType];
paymentType.creditCard = creditCardType;
ExtendedAmountType *extendedAmountTypeTax = [ExtendedAmountType extendedAmountType];
extendedAmountTypeTax.amount = #"0";
extendedAmountTypeTax.name = #"Tax";
ExtendedAmountType *extendedAmountTypeShipping = [ExtendedAmountType extendedAmountType];
extendedAmountTypeShipping.amount = #"0";
extendedAmountTypeShipping.name = #"Shipping";
LineItemType *lineItem = [LineItemType lineItem];
lineItem.itemName = #"Soda";
lineItem.itemDescription = #"Soda";
lineItem.itemQuantity = #"1";
lineItem.itemPrice = #"1.00";
lineItem.itemID = #"1";
TransactionRequestType *requestType = [TransactionRequestType transactionRequest];
requestType.lineItems = [NSArray arrayWithObject:lineItem];
requestType.amount = #"1.00";
requestType.payment = paymentType;
requestType.tax = extendedAmountTypeTax;
requestType.shipping = extendedAmountTypeShipping;
CreateTransactionRequest *request = [CreateTransactionRequest createTransactionRequest];
request.transactionRequest = requestType;
request.transactionType = AUTH_ONLY;
request.anetApiRequest.merchantAuthentication.mobileDeviceId =
[[[UIDevice currentDevice] uniqueGlobalDeviceIdentifier]
stringByReplacingOccurrencesOfString:#"-" withString:#"_"];
request.anetApiRequest.merchantAuthentication.sessionToken = sessionToken;
[an purchaseWithRequest:request];
}
i am getting the response as
Create Transaction response
2012-07-26 19:14:00.131 Authorized[2355:207] ErrorE00003The element 'merchantAuthentication' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has invalid child element 'mobileDeviceId' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'. List of possible elements expected: 'name, transactionKey, sessionToken, password' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'.
namespace warning : xmlns: URI AnetApi/xml/v1/schema/AnetApiSchema.xsd is not absolute
ttp://www.w3.org/2001/XMLSchema" xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"
^
2012-07-26 19:14:00.131 Authorized[2355:207] Error = (null)
2012-07-26 19:14:00.247 Authorized[2355:207] babul output is Message.code = E00003
Message.text = The element 'merchantAuthentication' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has invalid child element 'mobileDeviceId' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'. List of possible elements expected: 'name, transactionKey, sessionToken, password' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'.
Is there any alternative to the above problem and how the transactions are going to be stored in authorized .net
(i created my test account, i am giving those credentials, i approved my device but later i am getting the above error)
Thanks in advance
I think you need to go for in app purchase because Apple will not approve application payment through any web service or API.