Restrict Countries and Cites in Flutter using session token - flutter

the following string of url correctly gives me locations within my country:
String autocompleteURL="https://maps.googleapis.com/maps/api/place/autocomplete/json?input=$placeName&key=$mapKey&sessiontoken=1234567890&components=country:my";` //no Error
'my' gives all cities in Malaysia.
However, I want to restrict it to malacca within malaysia.I don't know how to use components for a particular city using session token.I searched the autocomplete documentation from google developers website.
After that, I changed the above code into:
String autocompleteURL= "https://maps.googleapis.com/maps/api/place/autocomplete/xml?input=$placeName&types=establishment&location=2.25386,-102.27273&radius=500&key=$mapKey"; //error after change.
However, only this line gives me error after change.
Here, long and latitude values are the values for Malacca.
I am using my program in flutter.

change your output type from xml to json :
String autocompleteURL= "https://maps.googleapis.com/maps/api/place/autocomplete/json?input=$placeName&types=establishment&location=2.25386,-102.27273&radius=500&key=$mapKey"; //error after change.

Related

SharePoint REST: Column does not exist error

I'm calling a REST API with a SharePoint Designer workflow on SharePoint online. I'm setting the column name with a variable, and when i put the variable into my URL to call it it says "Column [name] does not exist".
Annoying part is when I call just /items? I can see the column in the result, but if I try select it or filter by it I get 'does not exist'. I have alot of these columns similarly named, and I get the error for all of them.
I am using the internal name, I have tried adding "OData_" to the front. I've tried typing the url manually in the browser and entering values (incase the variable was causing issues) but I get the same error, column does not exist. but i can see it them I call all items. :(
so I have quite a few columns with naming convention "[Q#] Score [#]" eg "Q4 Score 2". The internal name that's clearly appearing in the full items results is "Q4_x0020_Score_x0020_2".
This works:
https://MYSITE.sharepoint.com/sites/portal/intranet/CorpServices/QSR/_api/web/lists/GetbyTitle('Audit')/Items?
and I get big full normal REST results that includes the line:
0
However if I try:
https://MYSITE.sharepoint.com/sites/portal/intranet/CorpServices/QSR/_api/web/lists/GetbyTitle('Audit')/Items?$Select=Q4_x0020_Score_x0020_2
Then I get:
-2146232832, Microsoft.SharePoint.SPExceptionColumn 'Q4_x0020_Score_x0020_2' does not exist. It may have been deleted by another user.
I expect to be able to select that column (and the dozens like it) but none work. I've searched all similar problems on the forum and they've usually got a spelling mistake or forgot the ODATA_ but i cant seem to get the problem. Please help.
It seemed to be working intermittently.... So it was in fact just a naming error...... Half of the columns were [Q#]_x0020_Score_x0020_[#] and half were [Q#]_x0020_score_x0020_[#]. The word "Score" was capitalized on some and not others. I Didn't realize the HTTP Calls were case sensitive. Now I have added a bunch of if statements to handle the different variations haha. Thanks for reading.
Judging by the naming convention you are on an older version of SharePoint. The x0020 is the value for a space. Ideally when you first create the column you would name it without the spacing. For example UserInformation. Then come in and edit the name after the fact and call it User Information. If you click on the title name and look at the URL, you will see what the actual name of the column is at the end of the URL. It is case sensitive because you can have a column named score and Score which is ultimately why it wasn't working.
Must load all fields like this
var lists = context.Web.Lists;
context.Load(lists);
context.ExecuteQuery();
CamlQuery query = new CamlQuery();
query.ViewXml = #"";
var list = lists.GetById("file.guid");
var listitems = list.GetItems(query);
context.Load(listitems);
context.ExecuteQuery();
var creationInformation = new ListItemCreationInformation();
var newItem=list.AddItem(creationInformation);
var fields = list.Fields;
context.Load(fields);
context.ExecuteQuery();

XPATH - /a/text(), cant extract email address (text)

I have simple HTML file with usernames and links to their sub-pages:
someUserName#domain.com
someUserName
I use
xpath('.//a/text()').extract_first()
to extract user name in plain text.
I have a problem when user specifies username in form of email (see first example) - empty object in returned in such case.
Edit: I have just noticed html has changed recently and I haven't rechecked:
<td><span class="__cf_email__" data-cfemail="3f4d565c544c5e514bwer4rwre58525e5653115c5052">[email protected]</span></td>
I'll extract from #href.
I have used the following code:-
import scrapy
inputString = '''<xmlData>
someUserName#domain.com
someUserName
</xmlData>'''
print scrapy.selector.Selector(text=inputString).xpath('.//a/text()').extract_first()
Output:-
someUserName#domain.com
Can you paste full python code? Because, xpath code seems working fine as:-
scrapy.selector.Selector(text=inputString).xpath('.//a/text()').extract_first()
Getting the text node children of an element (using text()) is generally discouraged, for exactly the reasons demonstrated here. With <a>content</a> you will get "content", with <a><span>content</span><a> you will get nothing, with <a>h<sub>2</sub>o</a> you will get two text nodes, "h" and "o".
Use string() to get the string value instead. The string value contains the concatenated content of all the descendant text nodes at any depth. ("content", "content", and "h2o" in these three examples).
Only reservation is that I don't know the Scrapy API so I don't know how it handles XPath expressions that return strings rather than nodes.

Query string parsing as number when it should be a string

I am trying to send a search input to a REST service. In some cases the form input is a long string of numbers (example: 1234567890000000000123456789). I am getting 500 error, and it looks like something is trying the convert the string to a number. The data type for the source database is a string.
Is there something that can be done in building the query string that will force the input to be interpreted as a string?
The service is an implementation of ArcGIS server.
More information on this issue per request.
To test, I have been using a client form provided with the service installation (see illustration below).
I have attempted to add single and double quotes, plus wildcard characters in the form entry. The form submission does not error, but no results are found. If I shorten the number("1234"), or add some alpha numeric characters ("1234A"), the form submission does not error.
The problem surfaced after a recent upgrade to 10.1. I have looked for information that would tie this to a known problem, but not found anything yet.
In terms of forcing the input to be interpreted as a string, you enclose the input in single quotes (e.g., '1234567890000000000123456789'). Though if you are querying a field of type string then you need to enclose all search strings in single quotes, and in that case none of your queries should be working. So it's a little hard to tell from the information you've provided what exactly you are doing and what might be going wrong. Can you provide more detail and/or code? Are you formatting a where clause that you are using in a Query object via one of Esri's client side API's (such as the JavaScript API)? In that case, for fields of data type string you definitely need to enclose the search text in single quotes. For example if the field you are querying were called 'FIELD', this is how you'd format the where clause:
FIELD = '1234'
or
FIELD Like '1234%'
for a wildcard search. If you are trying to enter query criteria directly into the Query form of a published ArcGIS Server service/layer, then there too you need to enclose the search in single quotes, as in the above examples.
According to an Esri help technician, this is known bug.

Google Places API autocomplete specific city

I have some questions about google places api for android.
This is the request that is being called:
https://maps.googleapis.com/maps/api/place/autocomplete/json?sensor=false&key=API_KEY&components=country:hr&language=hr&input=lad
The issue is that I want only addresses within specific city. Is that possible?
Here is the quote from
Google Places API autocomplete
that suggests that it should work.
Blockquote the (regions) type collection instructs the Place service to return any result matching the following types:
locality
sublocality
postal_code
country
administrative_area1
administrative_area2
Blockquote the (cities) type collection instructs the Place service to return results that match either locality or administrative_area3.
So I would like to specify citry or a postal code in order to filter only addreses from that city.
--EDIT--
This approach doesn't work either.
maps.googleapis.com/maps/api/place/autocomplete/json?sensor=false&key=API_KEY&types=geocode&location=45.811093,15.974121&radius=12000&components=country:hr&language=hr&input=lad
Solution
I've added CIty name in input string
city_name+street like Zagreb+fal in order to get all the streets from Zagreb with fal* in their name.
It seems to be working oke.

Get statuscode text in C#

I'm using a plugin and want to perform an action based on the records statuscode value. I've seen online that you can use entity.FormattedValues["statuscode"] to get values from option sets but when try it I get an error saying "The given key was not present in the dictionary".
I know this can happen when the plugin cant find the change for the field you're looking for, but i've already checked that this does exist using entity.Contains("statuscode") and it passes by that fine but still hits this error.
Can anyone help me figure out why its failing?
Thanks
I've not seen the entity.FormattedValues before.
I usually use the entity.Attributes, e.g. entity.Attributes["statuscode"].
MSDN
Edit
Crm wraps many of the values in objects which hold additional information, in this case statuscode uses the OptionSetValue, so to get the value you need to:
((OptionSetValue)entity.Attributes["statuscode"]).Value
This will return a number, as this is the underlying value in Crm.
If you open up the customisation options in Crm, you will usually (some system fields are locked down) be able to see the label and value for each option.
If you need the label, you could either do some hardcoding based on the information in Crm.
Or you could retrieve it from the metadata services as described here.
To avoid your error, you need to check the collection you wish to use (rather than the Attributes collection):
if (entity.FormattedValues.Contains("statuscode")){
var myStatusCode = entity.FormattedValues["statuscode"];
}
However although the SDK fails to confirm this, I suspect that FormattedValues are only ever present for numeric or currency attributes. (Part-speculation on my part though).
entity.FormattedValues work only for string display value.
For example you have an optionset with display names as 1, 2, 3,
The above statement do not recognize these values because those are integers. If You have seen the exact defintion of formatted values in the below link
http://msdn.microsoft.com/en-in/library/microsoft.xrm.sdk.formattedvaluecollection.aspx
you will find this statement is valid for only string display values. If you try to use this statement with Integer values it will throw key not found in dictionary exception.
So try to avoid this statement for retrieving integer display name optionset in your code.
Try this
string Title = (bool)entity.Attributes.Contains("title") ? entity.FormattedValues["title"].ToString() : "";
When you are talking about Option set, you have value and label. What this will give you is the label. '?' will make sure that the null value is never passed.