What causes the InvalidEntity exception in the SFDC bulk api? - salesforce

When creating a new bulk job through the API, I am getting an InvalidEntity as an exception code which isn't in SFDC's docs (pdf)
I'm making the following request
https://na13-api.salesforce.com/services/async/24.0/job
<?xml version="1.0" encoding="UTF-8"?>
<jobInfo xmlns="http://www.force.com/2009/06/asyncapi/dataload">
<operation>query</operation>
<object>Campaign</object>
<concurrencyMode>Parallel</concurrencyMode>
<contentType>CSV</contentType>
</jobInfo>
And I get this response:
<?xml version="1.0" encoding="UTF-8"?><error
xmlns="http://www.force.com/2009/06/asyncapi/dataload">
<exceptionCode>InvalidEntity</exceptionCode>
<exceptionMessage>Entity 'Campaign' is not supported by the Bulk API.</exceptionMessage>
</error>
I've excluded the headers but I do have accept & content encoding specified as gzip and the content is gzipped when it is sent and received.
The requests work correctly for
Lead
Contact
Opportunity
Task
Event
OpportunityContactRole
Account
CampaignMember
Note
Profile
RecordType
User
I only get the exception shown above for:
Campaign
UserLicense
OpportunityStage
OpportunityHistory
LeadHistory
I'm only using the bulk api to download csv's out of salesforce and I've only tried the above entities because I don't need any others.

It has been a very long time, but I think you can get this exception if one of your foreign key relationships is incorrect.

Related

Logic App Function to remove file extension

I have a logic app in Azure. The trigger is to check when an email arrives into a specific folder in a mailbox. An email may contain 1 or more attachments.
Once triggered, I have an HTTP request that gets sent to a SOAP service. The idea is that I want to check if the filename exists at the SOAP Service.
Its all working perfectly, with the exception, when I reference the filename from the trigger, it includes the file extension. I need to somehow ignore the ".PDF" part of the filename
Below is the XML I post to the SOAP service. Lets say the filename is 12345.pdf, then I need /UniversalEvent/Event/ContextCollection/Context/Value to = "12345" and not "12345.pdf":
<UniversalEvent xmlns="http://www.cargowise.com/Schemas/Universal/2011/11" version="1.1">
<Event>
<DataContext>
<DataTargetCollection>
<DataTarget>
<Type>ForwardingShipment</Type>
</DataTarget>
</DataTargetCollection>
</DataContext>
<EventTime>#{utcNow()}</EventTime>
<EventType>Z77</EventType>
<EventReference>Requesting Shipment ID</EventReference>
<IsEstimate>false</IsEstimate>
<ContextCollection>
<Context>
<Type>HAWBNumber</Type>
<Value>#{items('For_each')?['name']}</Value>
</Context>
</ContextCollection>
</Event>
</UniversalEvent>
do you have any suggestions on what function to use to achieve this?
You can change the expression #{items('For_each')?['name']} in your xml to:
#{substring(items('For_each')?['name'], 0, indexOf(items('For_each')?['name'], '.'))}

Salesforce Bulk API - "missing a mapping for the external id field" error

I'm starting a bulk API job and passing a spec file. Here is the job.txt file I'm using to create the job:
<?xml version="1.0" encoding="UTF-8"?>
<jobInfo xmlns="http://www.force.com/2009/06/asyncapi/dataload">
<operation>upsert</operation>
<object>Contact</object>
<externalIdFieldName>Unique_Email__c</externalIdFieldName>
<contentType>CSV</contentType>
</jobInfo>
Then, I'm posting a spec file as follows:
Salesforce Field,Csv Header,Value,Hint
Unique_Email__c,email1,,
Name,Full Name,,
And I get the error "Transformation specification is missing a mapping for the external id field" but that's very strange because the Unique_Email__c is actually there. What's going on?

Issue with stock update on amazon with mws

We are using the following details for updating the quantity of a product in amazon. Wile using scratch pad, option Feeds->SubmitFeed
Set the required parameters and pass the following XML
<?xml version="1.0" encoding="utf-8" ?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>$merchantID</MerchantIdentifier>
</Header>
<MessageType>Inventory</MessageType>
<Message>
<MessageID>1</MessageID>
<OperationType>Update</OperationType>
<Inventory>
<SKU>$SKU</SKU>
<Quantity>8</Quantity>
</Inventory>
</Message>
</AmazonEnvelope>
feed type : _POST_INVENTORY_AVAILABILITY_DATA_
we are getting in response for the same - submissionid. I know it takes sometime to update. But i waited and waited .. 4 atleast 15 hrs (not minutes) but it still was in process and the quantity was never updated.
Am getting in the following response
<?xml version="1.0"?>
<SubmitFeedResponse xmlns="http://mws.amazonaws.com/doc/2009-01-01/">
<SubmitFeedResult>
<FeedSubmissionInfo>
<FeedSubmissionId>6791310806</FeedSubmissionId>
<FeedType>_POST_INVENTORY_AVAILABILITY_DATA_</FeedType>
<SubmittedDate>2013-03-21T19:48:37+00:00</SubmittedDate>
<FeedProcessingStatus>_SUBMITTED_</FeedProcessingStatus>
</FeedSubmissionInfo>
</SubmitFeedResult>
<ResponseMetadata>
<RequestId>fd07bf18-4f6a-4786-bdf9-9d4db50956d0</RequestId>
</ResponseMetadata>
</SubmitFeedResponse>
and getting in following response on checking the status of the feed
<?xml version="1.0"?>
<ErrorResponse xmlns="http://mws.amazonaws.com/doc/2009-01-01/">
<Error>
<Type>Sender</Type>
<Code>FeedProcessingResultNotReady</Code>
<Message>Feed Submission Result is not ready for Feed Submission Id: 6791310806</Message>
<Detail/>
</Error>
<RequestID>2c86128d-b53a-4fc3-80d1-6b41b53a8977</RequestID>
</ErrorResponse>
Can any1 guide me.. where did i go wrong .. in here? or if there is any better way to look on for the same.
The time it seems to be taking isn't normal. Submitted feeds usually switch to _IN_PROGRESS_ within a few minutes and then take another few minutes to complete, when the status switches to _DONE_. Short feeds like your example feed should take less than a minute to process.
In the past, I've seen one feed upload blocking another though. It seems that sometimes the MWS won't start processing one feed until a previous feed of the same user has gone trough (or for that matter: failed). Please check if you have other request that might block yours (GetFeedSubmissionList)
Apart from this, the answers you are getting from Amazon MWS are perfectly normal. Your feed was accepted and put into the processing queue. The queue status was set to _SUBMITTED_, and as long as it hasn't switched to DONE, you will get the FeedProcessingResultNotReady answer you were seeing.

RequestThrottling issue in Amazon MWS API

I am testing API Sample of Amazon MWS API in C# for submit feeds however after setting AWS Secret key , access key etc. in code i am getting error of RequestThrottled , so there is details what is that but could not find any code sample how to resolved that.
I would like to upload feed.xml to amazon seller account
<?xml version="1.0" encoding="iso-8859-1"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>M_EXAMPLE_123456</MerchantIdentifier>
</Header>
<MessageType>Product</MessageType>
<PurgeAndReplace>true</PurgeAndReplace>
<Message>
<MessageID>1</MessageID>
<OperationType>Insert</OperationType>
<Product>
<SKU>56789</SKU>
<StandardProductID>
<Type>ASIN</Type>
<Value>B0EXAMPLEG</Value>
</StandardProductID>
<ProductTaxCode>A_GEN_NOTAX</ProductTaxCode>
<DescriptionData>
<Title>Example Product Title</Title>
<Brand>Example Product Brand</Brand>
<Description>This is an example product description.</Description>
<BulletPoint>Example Bullet Point 1</BulletPoint>
<BulletPoint>Example Bullet Point 2</BulletPoint>
<MSRP currency="USD">25.19</MSRP>
<Manufacturer>Example Product Manufacturer</Manufacturer>
<ItemType>example-item-type</ItemType>
</DescriptionData>
<ProductData>
<Health>
<ProductType>
<HealthMisc>
<Ingredients>Example Ingredients</Ingredients>
<Directions>Example Directions</Directions>
</HealthMisc>
</ProductType>
</Health>
</ProductData>
</Product>
</Message>
</AmazonEnvelope>
Error getting as per below
Caught Exception: Request from SubmitFeed:AKIAJI4PSK4HXY6UCNMA;A2DNAGZJ1EWQLW is
throttled.
Response Status Code: ServiceUnavailable
Error Code: RequestThrottled
Error Type: Sender
Request ID: fc59c802-04da-4dd3-89a8-db5f525cac39
XML: <ErrorResponse xmlns="http://mws.amazonaws.com/doc/2009-01-01/"><Error><Typ
e>Sender</Type><Code>RequestThrottled</Code><Message>Request from SubmitFeed:AKI
AJI4PSK4HXY6UCNMA;A2DNAGZJ1EWQLW is throttled.</Message><Detail>System.Object</D
etail></Error><RequestId>fc59c802-04da-4dd3-89a8-db5f525cac39</RequestId></Error
Response>
How can this be resolved?
As per Amazon's API reference the SubmitFeed operation has a maximum request quota of 15 and a restore rate of a request every 2 minutes. This means that you're allowed to make calls to this operation in burst of 15, but after this you're throttled for 2 minutes, until Amazon allows you to make another request.
You can find this better explained in their developer guide where they describe better how they make use of the leaky bucket algorithm.
Probably there isn't anything wrong with your feed, but because you made too many requests (probably more than 15) you got throttled. My advice is to build your code in such a way that you take into consideration Amazon throttlening and have a back-off algorithm when you're being throttled (like come back after a "restore rate" period, specific to the type of call you're doing). Also, keep in mind that another limitation MWS has is of 10000 requests per hour across all type of calls.

Google App Engine time out?

In a Google App Engine app I used the following lines to read a page from a site :
String Url="http://...",line,Result="";
URL url=new URL(Url+"?r="+System.currentTimeMillis());
BufferedReader reader=new BufferedReader(new InputStreamReader(url.openStream()));
while ((line=reader.readLine())!=null) { Result+=line+"\n"; }
reader.close();
But I got the following error :
Uncaught exception from servlet
com.google.apphosting.api.DeadlineExceededException: This request (f5e2889605d27d42) started at 2011/09/07 03:20:41.458 UTC and was still executing at 2011/09/07 03:21:30.888 UTC.
at sun.misc.Unsafe.park(Native Method)
at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedNanos(AbstractQueuedSynchronizer.java:1037)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.tryAcquireSharedNanos(AbstractQueuedSynchronizer.java:1326)
at com.google.common.util.concurrent.AbstractFuture$Sync.get(AbstractFuture.java:276)
at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:82)
at com.google.appengine.tools.development.TimedFuture.get(TimedFuture.java:55)
at com.google.common.util.concurrent.ForwardingFuture.get(ForwardingFuture.java:69)
at com.google.apphosting.runtime.ApiProxyImpl.doSyncCall(ApiProxyImpl.java:177)
at com.google.apphosting.runtime.ApiProxyImpl.access$000(ApiProxyImpl.java:56)
at com.google.apphosting.runtime.ApiProxyImpl$1.run(ApiProxyImpl.java:150)
at com.google.apphosting.runtime.ApiProxyImpl$1.run(ApiProxyImpl.java:148)
at java.security.AccessController.doPrivileged(Native Method)
Seems it took longer than it would like to wait, what can I do if that site is slow ?
A DeadlineExceededException is thrown when your code, handling the request to your web application takes over 30 seconds to process. Presumably your code is taking a while to process because of the length of time it had to wait to receive data from some other site.
You can create a task on a task queue to fetch and process that data, and change your web request/response flow to reply with progress on your task.
If your code is running inside a request handler, then by default there is an App-Engine-enforced 60 second deadline. You can't change it. See the "Deadlines" row / "automatic scaling" column of the chart on this page under "Scaling types":
https://developers.google.com/appengine/docs/java/modules/
However, this code will be able to run for some hours if you change your module to use "manual scaling" and a "B1"-"B4" instance. Example:
default/src/main/webapp/WEB-INF/appengine-web.xml:
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>myapp</application>
<module>default</module>
<version>1</version>
<threadsafe>true</threadsafe>
<instance-class>B1</instance-class>
<manual-scaling>
<instances>1</instances>
</manual-scaling>
</appengine-web-app>
On this type of instance, your requests will typically not time out for hours. (The documentation claims that the deadline is "indefinite".)

Resources