Socrata Full dataset replace API - socrata

I've been trying to follow the API docs for a full replace, by POSTing the payload to the dataset's endpoint (/resource/~ID~.json). I'm being returned the following object, which shows nothing actually happened.
{
"By RowIdentifier" : 0,
"Rows Updated" : 0,
"Rows Deleted" : 0,
"Rows Created" : 0,
"Errors" : 0,
"By SID" : 0
}
The endpoint i'm hitting is a working copy, and all other kinds of authenticated requests I've made to the endpoints work, but just can't get the dataset replace to work.
Any ideas?

Related

Why is Google Apps Script giving me this UrlFetchApp script code 429?

I have been having a strange error that I have been going in circles trying to figure out.
I decided to learn some JavaScript/google apps script to parse some information from an api of a game I play. I followed a bunch of tutorials and searched google and Stack Overflow for solutions but none have worked. I think I've narrowed it down to one particular Method: the "UrlFetchApp."
Right now I'm simply trying to grab some JSON data from the API and display it in the log window.
I keep getting this:
[21-09-13 09:01:40:770 EDT] Exception: Request failed for https://api.guildwars2.com returned code 429. Truncated server response: {"text":"too many requests"} (use muteHttpExceptions option to examine full response)
at getRequest(Untitled:4:30)
Now here's the strange part, I ran the script from my phone at work to test some theories out and got this:
[21-09-13 09:02:20:943 EDT] {
"name": "Abomination Hammer",
"type": "Weapon",
"level": 0,
"rarity": "Fine",
"vendor_value": 0,
"default_skin": 5014,
"game_types": [
"Activity",
"Wvw",
"Dungeon",
"Pve"
],
"flags": [
"NoSell",
"SoulbindOnAcquire",
"SoulBindOnUse"
],
"restrictions": [],
"id": 15,
"chat_link": "[&AgEPAAAA]",
"icon": "https://render.guildwars2.com/file/E8507FFB6CF3C9094A69956344CEDBD9B47D95B6/434872.png",
"details": {
"type": "Hammer",
"damage_type": "Physical",
"min_power": 146,
"max_power": 165,
"defense": 0,
"infusion_slots": [],
"attribute_adjustment": 20.736,
"infix_upgrade": {
"id": 112,
"attributes": []
},
"secondary_suffix_item_id": ""
}
}
I doubt it's the code now.
That is what was supposed to be returned. It's the same code unedited and ran multiple times on both my phone and computer and the results are always the same.
Here's the line of code I wrote:
function getRequest() {
var response = UrlFetchApp.fetch('https://api.guildwars2.com/v2/items/15');
Logger.log(response)
}
Can anyone help? I'm really frustrated now.
Response status code 429 shows when a user sent too many requests in a given amount of time. Based on the documentation of Rate Limiting in Guild Wars the rate limit is tracked per-IP and the maximum request per minute is 600.
In your script, you can confirm the rate limit by printing the header by using response.getAllHeaders() or response.getHeaders() and you will see x-rate-limit-limit=600.
X-Rate-Limit-Limit is the maximum number of requests that may be
issued within a minute. This is a static value doesn’t contain count
for requests you have already sent.
Usually, 429 status code includes Retry-After header. This indicates how long a user must wait before making a new request. You can also view this by printing the header.
If the Retry-After is not included in the headers, you can follow Elchanan shuky Shukrun comment above to use VPN since the rate limit is tracked per IP. You can also use the Guild Wars forum and create a post for a possible bug.
Reference:
429 Too Many Requests
Retry-Limit

ADF V2 - Web POST method using Dynamic Content and Variable

Very short version
How do I include an ADF Variable inside a JSON POST request, in a Web Activity within ADF?
I feel like this should be a very simple string concatenation, but i can't get it to work
Detail
We have a requirement to run a query / SProc from within ADF, which will return a string containing an error message. That string is to then be passed via the Web Activity in ADF to a Logic App, in order to fire off an email, containing the error.
The setup of the logic app is copied from here:
https://www.mssqltips.com/sqlservertip/5718/azure-data-factory-pipeline-email-notification--part-1/
and then here (part 2)
https://www.mssqltips.com/sqlservertip/5962/send-notifications-from-an-azure-data-factory-pipeline--part-2/
In ADF, I used the Lookup activity, to run a query, which brings back the error (appears to work, the preview returns the correct string)
Then I use the Set Variable activity, to take the output of the lookup and store it in a variable.
Last Step is to fire off the POST using the Web Activity.
With this code (tweaked slightly to remove personal details) in my Web Activity, everything works fine and I receive an email
{
"DataFactoryName": "#{pipeline().DataFactory}",
"PipelineName": "#{pipeline().Pipeline}",
"Subject": "Pipeline finished!",
"ErrorMessage": "Everything is okey-dokey!",
"EmailTo": "me#myEmail.com"
}
But any attempt to put the contents of the Variable into the Subject part has failed.
This (for example) sends me an email with the subject literally being #variables('EmailSubject')
{
"DataFactoryName": "#{pipeline().DataFactory}",
"PipelineName": "#{pipeline().Pipeline}",
"Subject": "#variables('EmailSubject')",
"ErrorMessage": "Everything is okey-dokey!",
"EmailTo": "me#myEmail.com"
}
But I've also attempted various other solutions that result in errors or the email subject just containing the literal thing that I put in there (e.g. + #variables('EmailSubject') +).
I also tried storing the entire JSON in the Variable, and then having the Web activity use only the variable, that returned no errors, but also did not send an email.
This attempt:
{
"DataFactoryName": "#{pipeline().DataFactory}",
"PipelineName": "#{pipeline().Pipeline}",
"Subject": "#{variables('EmailSubject')}",
"ErrorMessage": "Everything is okey-dokey!",
"EmailTo": "me#myEmail.com"
}
Resulted in this input into the web activity - which actually includes the text of the error, which is a bonus ... (text = Job Duration Warning):
{
"url": "https://azureLogicAppsSiteHere",
"method": "POST",
"headers": {
"Content-Type": "application/json"
},
"body": "{\n \"DataFactoryName\": \"DFNAMEHERE\",\n \"PipelineName\": \"pipeline1\",\n \"Subject\": \"{\"firstRow\":{\"\":\"Job Duration Warning\"},\"effectiveIntegrationRuntime\":\"DefaultIntegrationRuntime (West Europe)\",\"billingReference\":{\"activityType\":\"PipelineActivity\",\"billableDuration\":[{\"meterType\":\"AzureIR\",\"duration\":0.016666666666666666,\"unit\":\"DIUHours\"}]},\"durationInQueue\":{\"integrationRuntimeQueue\":0}}\",\n \"ErrorMessage\": \"Everything is okey-dokey!\",\n \"EmailTo\": \"me#myEmail.com\"\n}\t"
}
But then resulted in this error:
{
"errorCode": "2108",
"message": "{\"error\":{\"code\":\"InvalidRequestContent\",\"message\":\"The request content is not valid and could not be deserialized: 'After parsing a value an unexpected character was encountered: f. Path 'Subject', line 4, position 17.'.\"}}",
"failureType": "UserError",
"target": "Web1",
"details": []
}
[Edit] The PREVIEW from the Lookup Activity is the text: Job Duration Warning BUT when I debug the pipeline, it lets me see the actual Output, which is this:
{
"count": 1,
"value": [
{
"": "Job Duration Warning"
}
],
"effectiveIntegrationRuntime": "DefaultIntegrationRuntime (West Europe)",
"billingReference": {
"activityType": "PipelineActivity",
"billableDuration": [
{
"meterType": "AzureIR",
"duration": 0.016666666666666666,
"unit": "DIUHours"
}
]
},
"durationInQueue": {
"integrationRuntimeQueue": 0
}
}
So it appears that the problem is that the Lookup Output isn't what I thought it was, so the variable can't be used in the Web Activity, as it contains unsupported characters or something along those lines.
I just tested this and it worked ok:
Create a String Parameter with the value Job Duration Warning
Set the Variable value to be #pipeline().parameters.ParamSubject
Include the variable in the web activity with an # in front of it
I then receive my expected email with the right subject. I just don't know how to get the string output of my query, into a variable / parameter, so that i can use it in the web activity.
I don't know how well this applies to other people's issues, but I found a solution that has worked for me.
In the SELECT query within the Lookup Activity - name the output (in my case, I called that column 'Subject'- i.e. SELECT xyz AS Subject
In the Lookup Activity, turn on the setting 'First Row Only'
In the Set Variable Activity, use the code: #activity('Lookup1').output.firstRow.subject
(where 'Lookup1' is the name of your Lookup Activity and Subject is the name of the column you are outputting)
In the Web Activity, reference the variable as follows:
{
"DataFactoryName": "#{pipeline().DataFactory}",
"PipelineName": "#{pipeline().Pipeline}",
"Subject": "#{variables('EmailSubject')}",
"ErrorMessage": "Everything is okey-dokey!",
"EmailTo": "me#myEmail.com"
}

Create Bucket in Couchbase using Http Post Request

I want to create a bucket in couchbase on runtime using a simple http post request. I have used the following link to do the task link
Raw request I generated on postman is as follows:-
http://:8091/pools/default/buckets?name=newbucket&bucketType=membase&ramQuotaMB=20&authType=none&replicaNumber=2&proxyPort=11215
But its giving me error:-
{
"errors": {
"authType": "invalid authType"
},
"summaries": {
"ramSummary": {
"total": 20191379456,
"otherBuckets": 16710107136,
"nodesCount": 2,
"perNodeMegs": 0,
"thisAlloc": 0,
"thisUsed": 0,
"free": 3481272320
},
"hddSummary": {
"total": 158247145472,
"otherData": 11366997180,
"otherBuckets": 68794932977,
"thisUsed": 0,
"free": 78085215315
}
}
}
I have used the basic auth as the username and password of the couchbase console.
Any idea whats wrong with the call.
I think the problem is that you're passing the parameters in the URL and not as part of the POST body. Since you're using Postman, check the "x-www-form-urlencoded" option and enter the various values there.
Here's a screenshot of an example, which returns a 202 (Accepted) response:

Socrata SODA within polygon is too complex

Using the Socrata SODA api for within_polygon an error is thrown stating that it is too complex.
https://www.dallasopendata.com/resource/x9pz-kdq9.json?$where=within_polygon(location,%20%27MULTIPOLYGON%20(((-96.79920%2032.77946,-96.807768%2032.7751,-96.7999%2032.76999,-96.79920%2032.77946)))%27)
{
"code" : "query.execution.queryTooComplex",
"error" : true,
"message" : "Only simple comparison filters are allowed",
"data" : {
"reason" : "validation.complex-filter"
}
}
Here is a working version:
https://data.cityofchicago.org/resource/yama-9had.json?$where=within_polygon(location,%20%27MULTIPOLYGON%20(((-87.63742446899414%2041.871733907393164,-87.64720916748047%2041.8687938398043,-87.6540756225586%2041.86080384272637,-87.64214515686035%2041.85287677909342,-87.63467788696289%2041.859141797891915,-87.62866973876953%2041.86329682898112,-87.63038635253906%2041.86789900978502,-87.64317512512207%2041.86380819876315,-87.64326095581055%2041.86591755588323,-87.63742446899414%2041.871733907393164)))%27)
You're using the old API endpoint, rather than the new one that supports within_polygon(...). You'll want to use this one instead. The query works as expected against that new endpoint:
https://www.dallasopendata.com/resource/5nug-crr9.json?$where=within_polygon(location,%20%27MULTIPOLYGON%20(((-96.79920%2032.77946,-96.807768%2032.7751,-96.7999%2032.76999,-96.79920%2032.77946)))%27)
For more details on the migration process, check out this entry in the API changelog.

Events in BOX api

When I try to get the events but entering a valid stream_position, I am getting the correct response. However, when I give stream_position = 0, I am getting a "out_of_date" message instead of getting the complete list of all the events in the box cache as claimed in the api documentation of box. Please find below the sequence of requests/response when stream_position is 0.
Request : Calling the get method for the url https://api.box.com/2.0/events
Response:
{u'next_stream_position': 1388316267169, u'entries': [], u'chunk_size': 0}
Request :Calling the options method for the url https://api.box.com/2.0/events
Response : {u'entries': [{u'url': u'http://2.realtime.services.box.net/subscribe?channel=c403627ae43a88af895d&stream_type=all', u'max_retries': u'10', u'retry_timeout': 610, u'type': u'realtime_server', u'ttl': u'10'}], u'chunk_size': 1}
Request:
http://2.realtime.services.box.net/subscribestream_position=0&stream_type=all&channel=%5Bu%27c403627ae43a88af895d%27%5D
Response :
{u'message': u'out_of_date', u'version': 1}
My mistake!
There is no need to use the long polling method. All we needed to do for this use case is to directly call events with parameter as zero.