Bing ads - Upload offline conversion - bing

I am trying to upload my offline conversions to bing ads through API. I am using below code. And for now I am using sandbox account to test it.
val authorizationData = AuthorizationData().apply {
developerToken = "BBD37VB98"
authentication = PasswordAuthentication("xyz", "xyz")
customerId = 0
accountId = 0
}
var bulkOfflineConversion = BulkOfflineConversion().apply {
clientId = "xyz"
offlineConversion = OfflineConversion().apply {
conversionCurrencyCode = "USD"
conversionName = "phone_sales"
conversionTime = Calendar.getInstance()
conversionValue = 10.00
microsoftClickId = "f894f652ea334e739002f7167ab8f8e3"
}
}
val uploadEntities = ArrayList<BulkEntity>()
uploadEntities.add(bulkOfflineConversion)
var entityUploadParameters = EntityUploadParameters().apply {
entities = uploadEntities
responseMode = ResponseMode.ERRORS_AND_RESULTS
resultFileDirectory = File("/tmp/")
resultFileName = "bing.csv"
overwriteResultFile = true
}
//BulkServiceManager(authorizationData).
var task = BulkServiceManager(authorizationData).uploadEntitiesAsync(entityUploadParameters, null).get()
val resultEntities = ArrayList<BulkEntity>()
task.forEach {
resultEntities.add(it)
}
task.close()
After executing above code I got following XML response
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:TrackingId xmlns:h="https://bingads.microsoft.com/CampaignManagement/v11">b0e0e060-70fd-4bc2-9f40-b1ebcf38adb6</h:TrackingId>
</s:Header>
<s:Body>
<GetBulkUploadStatusResponse xmlns="https://bingads.microsoft.com/CampaignManagement/v11">
<Errors xmlns:i="http://www.w3.org/2001/XMLSchema-instance" i:nil="true" />
<ForwardCompatibilityMap xmlns:a="http://schemas.datacontract.org/2004/07/System.Collections.Generic" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" />
<PercentComplete>100</PercentComplete>
<RequestStatus>Completed</RequestStatus> <ResultFileUrl>https://bingadsappsstoragesi.blob.core.windows.net/bulkuploadresultfiles/6883bbd6-cdd5-4f1b-b1cf-65995601afd0.zip?sv=2015-12-11&sr=b&sig=%2B74DyfhzKeamKIMLIrHLyH93rwU3WNk6necXpULCrDk%3D&st=2018-04-30T05%3A43%3A16Z&se=2018-04-30T06%3A08%3A16Z&sp=rl</ResultFileUrl>
</GetBulkUploadStatusResponse>
</s:Body>
</s:Envelope>`
But When I logged into my account, I don't see any record. Can somebody help me in uploading my offline records.
Am I missing out something here. Do I need to configure anything else in my sandbox account?

Suggestions have been proposed in the Bing Ads API Development Forum and I confirmed that sandbox will not record the offline conversion data. I hope this helps!

Related

Magento rest api getting error Request does not match any route

I have created a rest api web service but I am getting error on hitting the url
http://localhost:81/magento/api/rest/category/2
<magento_api>
<messages>
<error>
<data_item>
<code>404</code>
<message>Request does not match any route.</message>
</data_item>
</error>
</messages>
</magento_api>
My api2.xml is:-
<?xml version="1.0"?>
<config>
<api2>
<resource_groups>
<esoft_rescategories translate="title" module="Esoft_Restcategories">
<title>Esoft Restcategories API</title>
<sort_order>11</sort_order>
</esoft_rescategories>
</resource_groups>
<resources>
<esoft_restcategories translate="title" module="Esoft_Restcategories">
<group>esoft_rescategories</group>
<model>esoft_restcategories/api2_restapi</model>
<title>Categories</title>
<sort_order>11</sort_order>
<privileges>
<admin>
<create>1</create>
<!--<retrieve>1</retrieve>
<update>1</update>
<delete>1</delete>-->
</admin>
<guest>
<retrieve>1</retrieve>
<!--<create>1</create>
<update>1</update>
<delete>1</delete>-->
</guest>
</privileges>
<attributes>
<category_id>Category ID</category_id>
<name>Name</name>
<parent_id>Category Parent ID</parent_id>
<child_id>Category Child List</child_id>
<active>Active</active>
<level>Level</level>
<position>Position</position>
</attributes>
<routes>
<route_entity>
<route>/categories/:cat_id</route>
<action_type>entity</action_type>
</route_entity>
<route_collection>
<route>/categories</route>
<action_type>collection</action_type>
</route_collection>
</routes>
<versions>1</versions>
</esoft_restcategories>
</resources>
</api2>
</config>
My version file for guest is:-
<?php
class Esoft_Restcategories_Model_Api2_Restapi_Rest_Guest_V1 extends Esoft_Restapi_Model_Api2_Restapi {
/**
* Retrieve list of category list.
*
* #return array
*/
protected function _retrieveCollection()
{
$ruleId = $this->getRequest()->getParam('cat_id');
// $cat_mod = Mage::getModel('catalog/category')->load($ruleId)->toArray();
$cats = Mage::getModel('catalog/category')->load($ruleId);
$subcats = Mage::getModel('catalog/category')->load($ruleId)->getChildren();
$cur_category = array();
$node['category_id'] = $ruleId;
$node['name'] = $cats->getName();
$node['parent_id'] = $cats->getParentId();
$node['child_id'] = $subcats;
if($cats->getIsActive()){
$node['active'] = 1;
}else{
$node['active'] = 0;
}
$node['level'] = $cats->getLevel();
$node['position'] = $cats->getPosition();
$cur_category[] = $node;
// $subcats = Mage::getModel('catalog/category')->load($ruleId)->getAllChildren();
// $subcats = Mage::getModel('catalog/category')->load($ruleId)->getChildren();
if($subcats != '')
{
foreach(explode(',',$subcats) as $subCatid)
{
$_category = Mage::getModel('catalog/category')->load($subCatid);
$childcats = Mage::getModel('catalog/category')->load($subCatid)->getChildren();
$node['category_id'] = $subCatid;
$node['name'] = $_category->getName();
$node['parent_id'] = $_category->getParentId();
$node['child_id'] = $childcats;
if($_category->getIsActive()){
$node['active'] = 1;
}else{
$node['active'] = 0;
}
$node['level'] = $_category->getLevel();
$node['position'] = $_category->getPosition();
$cur_category[] = $node;
}
}
return $cur_category;
}
}
Please let me know how to fix this error.
Also let me know on what basis we define routes.
Simple answer for those searching for cause of this error:
Request does not match any route
Is that you are posting the wrong METHOD such as GET/POST/PUT/DELETE.
It could also be the path of the API url itself is wrong.
As per your description your url format is wrong (route miss matching in given url).
<route>/categories/:cat_id</route>
^^^^^^^^^
So you need to change the url like below
http://localhost:81/magento/api/rest/categories/2

How to set content-Type on WCF request

My issue is that a testing app like Google Postman (awesome tool, found here) can send the message.
When I send the message it's always refused (the exact same message) because nonse is 'expired'.
So there must be something different about how I'm sending it...
There is... Content-Type is different, for one... but not sure if that's why...
I've seen some hints about accessing endpoint behaviours like:
var whb = client.ChannelFactory.Endpoint.Behaviors.Find<WebHttpBehavior>();
But that only allows me to choose between xml and json.
whb.AutomaticFormatSelectionEnabled = false;
whb.DefaultOutgoingRequestFormat = WebMessageFormat.Xml;
I have a wsdl:
http://caqh.org/SOAP/WSDL/CORERule2.2.0.wsdl
I need to call the WCF service's RealTimeTransaciton with headers that that are:
Content-Type: application/soap+xml;charset=UTF-8;
Currently, by default I suppose, the call includes headers;
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
and Content-Type doesn't seem to be set.
So I tried to affect the headers of the request...
var addressHeaders = new List<AddressHeader> {
AddressHeader.CreateAddressHeader("Content-Type", "", "application/soap+xml;charset=UTF-8;"),
AddressHeader.CreateAddressHeader("Cache-Control", "", "no-cache"),
AddressHeader.CreateAddressHeader("Accept", "", "application/soap+xml;charset=UTF-8;")
};
var client = new CORETransactionsClient(binding, new EndpointAddress(new Uri(url),addressHeaders.ToArray()));
But to my surprise, the result of this is that these 'headers' are added within the soap Envelope headers, and not the headers for the transport!
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<s:Header>
<Content-Type>application/soap+xml;charset=UTF-8;</Content-Type>
<Cache-Control>no-cache</Cache-Control>
<Accept>application/soap+xml;charset=UTF-8;</Accept>
<o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
etc.... lol
My web.config service model:
<system.serviceModel>
<bindings>
<customBinding>
<binding name="CoreSoapBinding">
<textMessageEncoding messageVersion="Soap12" writeEncoding="UTF8" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="https://my_vendor_url_for_service_that_is_Axis2_based" binding="customBinding"
bindingConfiguration="CoreSoapBinding" contract="CoreRule.CORETransactions"
name="CoreSoapPort"
endpointConfiguration="">
</endpoint>
</client>
</system.serviceModel>
How I call:
var msg = Create270X12Message(requestReferenceId, senderId, receiverId, requestDateStr, productionCall, prettyOutput);
var envelope = new COREEnvelopeRealTimeRequest
{
CORERuleVersion = "2.2.0",
Payload = string.Format("<![CDATA[{0}]]>", Convert.ToBase64String(Encoding.UTF8.GetBytes(msg))),
PayloadID = requestReferenceId.ToString(),
PayloadType = CoreRule2PayloadType_270_5010,
ProcessingMode = CoreRule2ProcessingMode_270_5010,
ReceiverID = receiverId,
SenderID = senderId,
TimeStamp = requestDateStr
};
var client = CreateRealTimeOnlineProxy(urlMissouiri, username, password, requestDateStr);
var response = client.RealTimeTransaction(envelope);
How can I add my collection of headers to the request itself, instead of the SOAP Envelope headers?

Accessing SOAP services with Google Apps Script

I'm trying to use Google Apps Scripts to call a SOAP service call, and I've been trying to tinker with a number of ways to get a response; however, I keep getting an error. I've defaulted to trying to send an exact copy of a message stored in my spreadsheet that I know works through another service... still no luck. Here's the Apps Script Code:
function getVesselSummaryXMLStringFromName() {
var wsdl = SoapService.wsdl("http://cgmix.uscg.mil/xml/PSIXData.asmx?WSDL");
Logger.log(wsdl.getServiceNames());
var uscgService = wsdl.getPSIXData();
var sheet = SpreadsheetApp.getActiveSheet();
//Get working SOAP message
var envelope = sheet.getRange("D1:D1").getValues();
Logger.log(envelope);
var result = uscgService.getenvelope;
Logger.log(result);
}
The SOAP message I'm sending that works through http://www.soapclient.com/soapclient is:
<?xml version="1.0" encoding="UTF-8" standalone="no"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://cgmix.uscg.mil" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" ><SOAP-ENV:Body><tns:getVesselSummaryXMLString xmlns:tns="http://cgmix.uscg.mil"><tns:VesselID></tns:VesselID><tns:VesselID></tns:VesselID><tns:VesselName>Atlantic Salvor</tns:VesselName><tns:VesselName></tns:VesselName><tns:CallSign></tns:CallSign><tns:CallSign></tns:CallSign><tns:VIN></tns:VIN><tns:VIN></tns:VIN><tns:HullNum></tns:HullNum><tns:HullNum></tns:HullNum><tns:Flag></tns:Flag><tns:Flag></tns:Flag><tns:Service></tns:Service><tns:Service></tns:Service><tns:BuildYear></tns:BuildYear><tns:BuildYear></tns:BuildYear></tns:getVesselSummaryXMLString></SOAP-ENV:Body></SOAP-ENV:Envelope>
The following code returns an answer, so maybe you can help.
...
var url = 'http://cgmix.uscg.mil/xml/PSIXData.asmx?WSDL';
var wsdl = SoapService.wsdl(url);
var servicePSIXData = wsdl.getPSIXData();
var params = Xml.element('getVesselSummaryXMLString', [
Xml.attribute('xmlns', 'http://cgmix.uscg.mil'),
Xml.element('VesselID', ['']),
Xml.element('VesselName', ['Atlantic Salvor']),
Xml.element('CallSign', ['']),
Xml.element('VIN', ['']),
Xml.element('HullNum', ['']),
Xml.element('Flag', ['']),
Xml.element('Service', ['']),
Xml.element('BuildYear', [''])
]);
var result = servicePSIXData.getVesselSummaryXMLString(params);
Logger.log(result.toXmlString());
...
UPDATE
Both Xml Services and Soap Services are considered deprecated.

Alfresco REST API:Data Size Limit?

I am developing REST based webservices in alfresco for data transfer & want to know what is the maximum amount of data i can send/get thru REST protocol?
Any reference would be very helpful.
Regards.
The max amount of data is as large as 2147000000. That's why if your data is large enough it is advisable to stream it to post to your REST service. Here's an example.
Sender/ Uploader Application or Client
var sb = new StringBuilder();
sb.Append("Just test data. You can send large one also");
var postData = sb.ToString();
var url = "REST Post method example http://localhost:2520/DataServices/TestPost";
var memoryStream = new MemoryStream();
var dataContractSerializer = new DataContractSerializer(typeof(string));
dataContractSerializer.WriteObject(memoryStream, postData);
var xmlData = Encoding.UTF8.GetString(memoryStream.ToArray(), 0, (int)memoryStream.Length);
var client = new WebClient();
client.UploadStringAsync(new Uri(url), "POST", "");
client.Headers["Content-Type"] = "text/xml";
client.UploadStringCompleted += (s, ea) =>
{
if (ea.Error != null) Console.WriteLine("An error has occured while processing your request");
var doc = XDocument.Parse(ea.Result);
if (doc.Root != null) Console.WriteLine(doc.Root.Value);
if (doc.Root != null && doc.Root.Value.Contains("1"))
{
string test = "test";
}
};
REST Service method
[WebInvoke(UriTemplate = "TestPost", Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest, RequestFormat = WebMessageFormat.Xml)]
public string Publish(string market,string sportId, Stream streamdata)
{
var reader = new StreamReader(streamdata);
var res = reader.ReadToEnd();
reader.Close();
reader.Dispose();
}
Don't forget to put the following configuration settings on your REST Service config file if you don't have this it will throw you an error
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime maxRequestLength="2147000000" maxQueryStringLength="2097151" maxUrlLength="2097151"/>
</system.web>
<system.webServer>
........
</system.webServer>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" maxReceivedMessageSize="2147000000" maxBufferPoolSize="2147000000" maxBufferSize="2147000000"/>
</webHttpEndpoint>
</standardEndpoints>
</system.serviceModel>

get latitude and longitude of a place against its zipcode

I have used the following code to get the location of the particular place on map using the following piece of code
NSString * urlString = [[NSString alloc] initWithFormat:#"http://maps.google.com/maps/geo?key=%#&output=xml&q=%#",GoogleMapsAPIKey,[placeName stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
result:
<?xml version="1.0" encoding="UTF-8" ?>
<kml xmlns="http://earth.google.com/kml/2.0"><Response>
<name>postdam</name>
<Status>
<code>200</code>
<request>geocode</request>
</Status>
<Placemark id="p1">
<address>Potsdam, Germany</address>
<AddressDetails Accuracy="4" xmlns="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0"><Country><CountryNameCode>DE</CountryNameCode><CountryName>Deutschland</CountryName><AdministrativeArea><AdministrativeAreaName>Brandenburg</AdministrativeAreaName><SubAdministrativeArea><SubAdministrativeAreaName>Potsdam</SubAdministrativeAreaName><Locality><LocalityName>Potsdam</LocalityName></Locality></SubAdministrativeArea></AdministrativeArea></Country></AddressDetails>
<ExtendedData>
<LatLonBox north="52.4513968" south="52.3424614" east="13.1866602" west="12.9305414" />
</ExtendedData>
<Point><coordinates>13.0586008,52.3969627,0</coordinates></Point>
</Placemark>
</Response></kml>
but now I want to get the information agianst the zipcode. How to do that using the maps.google.com?
You no longer need to use the google maps API key to access this API.
Below is a PHP function I wrote yesterday to achieve exactly this in JSON
function getCoordinatesFromAddress($address, $lat, $long, $region="US") {
$json = file_get_contents("http://maps.google.com/maps/api/geocode/json?address=$address&sensor=false&region=$region");
$json = json_decode($json);
$lat = $json->{'results'}[0]->{'geometry'}->{'location'}->{'lat'};
$long = $json->{'results'}[0]->{'geometry'}->{'location'}->{'lng'};
}
Since Google Maps is US centric, just putting in the zip code directly works (at least for the moment)
http://maps.google.com/maps/geo?output=xml&q=90210
<AdministrativeArea>
<AdministrativeAreaName>CA</AdministrativeAreaName>
<SubAdministrativeArea>
<SubAdministrativeAreaName>Los Angeles</SubAdministrativeAreaName>
<Locality>
<LocalityName>Beverly Hills</LocalityName>
<PostalCode>
<PostalCodeNumber>90210</PostalCodeNumber>
</PostalCode>
</Locality>
</SubAdministrativeArea>
</AdministrativeArea>