I do not have much experience with salesforce api. We have been using following api: /services/data/v21.0/sobjects/Lead to post leads to salesforce, which has been working fine till now. We are already tracking first name, last name, email and company.
Now we want to track one custom attribute, gclid too. We have added that as lead attribute on salesforce, but are getting following error even after allowing edit access to that field. We have tried adding _c suffix too, with no success. Any suggestions?
Error: "[{\"message\":\"No such column 'GCLID_c' on sobject of type Lead\",\"errorCode\":\"INVALID_FIELD\"}]"
We have tried various approaches as suggested when you google for above mentioned error. None have worked so far.
{
'method': 'POST',
'url': 'https://' + SALESFORCE_HOST + '/services/data/v21.0/sobjects/Lead',
'headers': {
'authorization': 'OAuth ' + sfToken,
'content-type': 'application/json'
},
'body': JSON.stringify({
{
"Email": "nitin+28#gmail.com",
"FirstName": "TestNitin1",
"LastName": "TestBansal1",
"Company": "WebEngage",
"GCLID_c": "test gclid"
}
})
};
Any suggestions please...
Thanks in advance
Custom fields' names end with __c, you have just one underscore in there?
Related
I'm New to SFCC OCAPI. My purpose is to Export all Orders from "development.demandware.net" after certain date and this can happen Quite frequently like once in every 2 days. I'm currently using Python to achieve this using the endpoint "s/{{SITEID}}/dw/shop/v18_1/order_search". The problem is One call is getting me only 25 Records. Again i have change the query from dynamically to start from RecordNo 26 for the next call. So, If I have like 10,000 records, it makes upto 400 calls everytime the scirpt runs. The alternative options i'm aware of is:
OCAPI Batch requests
OCAPI Export job (Tried this, but haven't got enough knowledge to set this up)
So, I'd like to know if my purposed is achievable using the batch request. I tried to do this using the documentation. And, the response was 200 with no response body using the below code.
url = f"https://{DOMAIN}/s/-/dw/batch"
url_param = {'client_id': CLIENT_ID}
header = {'Authorization': 'Bearer ' + token,
'Origin': f'https://{DOMAIN}',
'Content-Type': 'multipart/mixed;boundary=23dh3f9f4',
'x-dw-http-method': 'POST',
'x-dw-resource-path': 's/{{SITEID}}/dw/shop/v18_8/order_search'}
body = """
{
"query" :
{
"filtered_query": {
"query": { "match_all_query": {} },
"filter": {
"range_filter": {
"field": "creation_date",
"from": "%s",
"from_inclusive": true
}
}
}
},
"select" : "(**)",
"sorts": [{
"field": "order_no",
"sort_order": "asc"
}],
"start": %s
}""" %(RETRIVE_RECORDS_FROM, startRecordFrom)
response = requests.post(url, params = url_param, headers = header, data = body)
My code doesn't have a x-dw-content-id as the above is an initial request. If its possible to achieve my purpose,
how should my sub-request looks like.?
And after that how do i retrieve the data of my request.? is there any endpoint i should use to get the batch results.?
I maybe asking for too much information. But, i couldn't find much information about this online so had to ask every question i have in one post.
My question might look similar to this question "Salesforce Commerce Cloud/Demandware - OCAPI query orders by date range", But I'm looking for information about batch requests and also to reduce the number of API calls.
Thanks in advance.
This question has been asked before but those solutions i have already tried and i shall
explain along the way.
Task:
I want to send data to api with content-type as "application/x-www-form-urlencoded".
Problem:
The URL works fine in Postman and returns me the correct response. When i try the same body parameters through my Reactjs app, it responds with 400 bad request error.
What i have tried:
myBody:{
grant_type:"XYZ",
client_id:"XYZ"
}
var request = {
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
method: "POST",
body:myBody
};
Then i fetch something like this.
const data = yield fetch(complete_url,request);
I also tried to compose myBody as a formData . Still gives the same error.
Apologies i have not given the URL because of restrictions. I am looking for possibilities of errors i could make.
With 'Content-Type': 'application/x-www-form-urlencoded',
Your request body should follow certain rule (https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST).
the keys and values are encoded in key-value tuples separated by '&', with a '=' between the key and the value,
example:
grant_type =value1&client_id=value2.
So i suggest what it looks like in debugger -> network tab.
If the request body is not a problem. Then you should check if there's any special chars.
You also will need to escape symbols and special chars.
I am sending a simple POST to a site and I want to collect the HTML content in which lies a hidden field with a VIEWSTATE value (old asp.net site).
The response when I debug the script is limited to 10168 chars... however, in the network viewer the response is complete, over 76000 chars. Does anyone know if this is an issue with the debugger or something else that limits the data received by a POST to just over 10k characters?
code:
$http({
url: aURL,
method: "GET",
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).then(function (response) {
... do stuff here ...
});
The issue revolves around Chrome debugger having a string limitation. It works fine when using Firefox.
On attempting to login via the truvault api using angular js, I am getting this error message: Failed to parse UUID. I am passing the username, password and account_id as params. I am successful using the curl command and get the success response.
The 400 error is not described in the api docs for authorization. I am not sure about if this UUID is linked to the schema_id. Would anyone (truevault guys!!) know what I am doing wrong?
I contacted truevault support on this one. Dan helped me get through it.
I was passing the username/password/account_id as url string query parameters. I had to make two changes to the code:
1. Pass the above as form data parameters
2. add the angular-post-fix.js to my project.
(Note: I am not adding the link as there are editors who will disallow the post with links to elsewhere. It has happened in the past!)
When using Node.js, the querystring API is really useful. Just pass an object to the querystring.stringify() function, and the resulting output is ready to be sent to TrueVault for login.
Additionally, I found that adding the header 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8' might be necessary (which is one of the things the Angular post-fix library does).
#orthodoc is right, but is kind of tricky how to actually build the request. Lets say we are using fetch with formData params, I'd like to add an example of a successful request:
...
var formData = new FormData();
formData.append('username', username);
formData.append('password', password);
formData.append('account_id', accountId);
return fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8'
},
body: formData
});
...
I am using the following plugin https://github.com/VividCortex/angular-recaptcha in order to use recaptcha at a login form.
I am using the following code for verification
$http({
url: 'https://www.google.com/recaptcha/api/verify',
method: 'POST',
params: {privatekey: "key", remoteip: "userip", challenge: "challenge", response: "user_answer" },
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}).success(function(data) {
console.log(data);
if (valid) {
console.log('Success');
alert('Success');
} else {
console.log('Failed validation');
alert('Fail');
// In case of a failed validation you need to reload the captcha because each challenge can be checked just once
//vcRecaptchaService.reload();
}
});
But google server is not returning anything.
I updated the code but no luck.
I think you have a typo in your code:
post: 'GET'
Change that to method: 'GET' or method: 'POST'.
You can check out angular documentation on http to make sure you've written all the params right.
If this wasn't the source of your problems, you should post more details about your issue (what do you see in your networkl console for example).
Keep in mind that recaptcha validation must be done at server-side. I'm not 100% sure that you are doing that in the browser, but your code looks like it.
As Miguel Trias stated, you shall not validate directly from angularjs/javascript client, instead you should send the challenge and response field to your server and validate then.
Therefore you can use the uri you used (https://www.google.com/recaptcha/api/verify) or a plugin, e.g. if you use php see https://developers.google.com/recaptcha/docs/php. I'd prefer a plugin because it will save work.
Furthermore keep in mind that your private key should not be used in the client, this is why it is called private. It is only used to communicate between your server and the reCaptcha servers. The public key is used to communicate between your client and the reCaptcha servers.
For more info read the Overview