Why are Title and Comment field for a contact always null? - tapkey

When I try to use Put or Patch for a contact object, the comment and title field always remain 'null'.
For instance, this is the json I use to perform a PUT:
{
"IpId" : "tapkey",
"Identifier" : "emailaddress here",
"Title" : "Test title",
"Comment" : "Test comment"
}
This executes with 200 OK. The contact that I immediately get return has the comment and title field set to 'null'. The contact is successfully created though.
For a PATCH the same thing happens.
Regards,
Stan

Field's names must start with lowercase letter.
For PUT request it actually works both ways. You can define it with e.g. Title or title and it will be accepted.
For PATCH request you are completely right, this only accepts lowercase letters. After changing this, it works as expected.
{
"title": "my title",
"comment": "my comment"
}
We will update our documentation to reflect this on PUT endpoint.

Never mind. I used a POST method to execute the PUT. Because the contact was created and a HTTP 200 was returned, I never saw this error.
So the behavior for sending a PUT body to the contacts URL using the POST method will result in:
HTTP 200
Creation of the contact, but without title and comment
Result is an array with 1 contact, the new one
Using the PUT method of course solved all my problems
Thanks anyway
Stan

Related

Postman null value in optional string field

I'm writing a POST request in Postman. There is an optional field, which can contain null or a date (a string value). So, I have this in my POST request body:
"paidOn": "{{date}}"
It works great with non-null values, obviously. But if I put null in the paidOn column, it ends up like a string "null". If I put nothing, it ends up like an empty string "". In both cases, I get a 400 error.
I tried another approach too:
"paidOn": {{date}}
This one works ok with empty fields, but doesn't when I have an actual date in it (like, 2020-04-13T14:39:52) -> I get a 400 error.
Does anyone know how I could work it out?
Alright, I found something in another forum, which gave me an idea: https://sqa.stackexchange.com/a/42484/25137
I kept the following format:
"paidOn": {{date}}
And in the CSV file:
paidOn
"""non-null-value"""
null
Works like a charm.

Django rest framework: How to change error response format globally

All the error messages return from django default validators ends with a dot (.). Is there anyway to remove that last dot from all messages globally.
Or, If someone help me to find a way to catch these error returning function, I can trim the last dot if exists in that section.
Sample error messages.
{
"email": [
"This field may not be blank."
]
}
{
"email": [
"Enter a valid email address."
]
}
You can use Restframework's exception handler. Please have a look.
If you want to change all of them, you should override the field's default messages somewhere in the application initialization:
serializers.CharField.default_error_messages['blank'] = 'This field may not be blank'
For example, the blank message can be found here

Can creationTime and other Directory meta-fields be used in a query?

I'm trying to filter the list of users returned from Directory.Users.List, and want to use the creationTime value in the filter. According to this:
Search for users
...you can use Date fields in comparisons, however when I try something like:
creationTime>=2016-06-30 (or the same value quoted)
...I get:
Caused by: com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
{
"code" : 400,
"errors" : [ {
"domain" : "global",
"message" : "Invalid Input: creationTime>=2016-06-30",
"reason" : "invalid"
} ],
"message" : "Invalid Input: creationTime>=2016-06-30"
}
The message isn't particularly helpful - is this a syntax issue with the query, or is it the case that the field isn't available for query (it isn't listed in that article, but it is part of the JSON response)?
The article specifies the format for Date field queries, however this field also includes a time component, so I tried to also replicate the exact format that shows in the JSON, with the same result.
Also, same result in the Try it! section of the Users reference page.
Also also, tried using a numeric value (Date.getTime(), in effect) - same error.
Thanks...
P.S. Interestingly, Google does document how to search on date fields for Chromebooks, and it's entirely different than they imply for users. I still can't use creationTime with this, but it does work for Chromebooks. The other part of this is that it refers to fields that aren't documented, and why I try to use the documented field (e.g. lastSync vs. sync), it fails with the same message. This whole thing seems half-baked.
View Chrome device information
Only the fields listed in the table are searchable via the users.list search.
A workaround (I don't know if this is suitable for you) may be to push the data you want to use in a search into custom user fields. These fields are searchable.

Can I use a Query String to drive personalized content in Sitecore 7.5?

I'm trying to display personalized content on a page IF I have clicked on a specific link on a specific page. My thought was to have a parameter on the link such as:
Go to product page
Then, on "Product Page", hopefully using the rules engine, check if the parameter home exists in the query string. If so, then display a piece of content.
I can't seem to figure out the best way to do this with Sitecore 7.5. Maybe this is the wrong approach.
Out of the box in Sitecore 7.5 there is no rule for using the querystring.
but you can easily create a rule and use with the personalize feature from Sitecore.
See http://blog.martinmiles.net/post/rules-engine-and-sitecore-personalization-based-on-url-query-string-parameters
for a complete description and Example include a link to github with the code
https://github.com/MartinMiles/Personalization
so you would have to have something like this:
public ActionResult Index(string name)
{
Student student = new Student();
student.Name = "John";
if (!String.IsNullOrEmpty(Request.QueryString["name"]))
{
student.Name = Request.QueryString["name"];
}
return View(student);
}
For this example, my controller is named Test. So if I want to call this method I would do ~/test/index, if I do that the student object will contain the name John, however if I do ~/test/index?name=Denis , I will send an object with the name Denis
Here the name will only change when we pass the query string "name" with a value.

FactoryGirl first created object used even when specify the second one

I can't really understand this. I have a course factory that I use to create two objects. When I visit the page for the Accounting course (as seen below) it displays the Marketing course page. However, if I use factory girl to create the accounting course first then it visits the correct page and the test passes.
describe "Course pages" do
subject { page }
let!(:published_course) { FactoryGirl.create(:course, title: 'Marketing') }
let!(:unpublished_course) { FactoryGirl.create(:course, title: 'Accounting') }
describe "displaying the right page" do
it "should display the accounting course page" do
visit course_path(unpublished_course)
expect(page).to have_content('Accounting')
end
end
end
It obviously visits the page of the object that is created first, but I don't know why or how to fix this.
Thanks,
Matt
course_path will generate the correct URL (i.e. containing the correct id param), but it's up to your controller to find the course for that id and pass it to your view. Instead, your controller/view must be conspiring to display the first course created.