SoundCloud created_at[from] query resolving in a 503 error - api

Using the JavaScript SDK, I am trying to search for all tracks in a given genre from a given date going forward (using the 'created_at[from]' /tracks filter).
My JavaScript for this is:
SC.get('/tracks', { genres: 'metal', created_at: {from: '2014-02-26 00:00:01'} }, function(tracks) {
console.log(tracks);
});
The request URL resolves as:
http://api.soundcloud.com/tracks?genres=metal&created_at[from]=2014-02-26%2000%3A00%3A01&client_id=MY_ID
and I get a 503. (I omitted posting my client_id here intentionally)
What am I doing wrong here?

Looks like they changed the filter or its a bug or they are working on it:
When i call:
http://api.soundcloud.com/tracks?limit=1&genres=metal&client_id=b45b1aa10f1ac2941910a7f0d10f8e28&created_at=2010-10-10
I am getting:
invalid filter.created_at=2010-10-10;
valid values are: last_year, last_two_weeks, last_week, last_day, last_hour
Then, when i call for last hour:
http://api.soundcloud.com/tracks?limit=1&genres=metal&client_id=b45b1aa10f1ac2941910a7f0d10f8e28&created_at=last_hour
I am getting a: 503 - Service Unavailable
When i change it to last_year, it works as expected,
and i get following xml (or json):
<tracks next-href="http://api.soundcloud.com/tracks?client_id=b45b1aa10f1ac2941910a7f0d10f8e28&created_at=last_year&genres=metal&limit=1&offset=1" type="array">
<track>
<kind>track</kind>
<id type="integer">103909859</id>
<created-at type="datetime">2013-08-04T01:30:44Z</created-at>
<user-id type="integer">29394873</user-id>
<duration type="integer">248917</duration>
<commentable type="boolean">true</commentable>
<state>finished</state>
<original-content-size type="integer">4696472</original-content-size>
<sharing>public</sharing>
<tag-list>
exotoxis metal femalevocals rock shredding army god double bass
</tag-list>
<permalink>army-of-god</permalink>
<streamable type="boolean">true</streamable>
<embeddable-by>all</embeddable-by>
<downloadable type="boolean">false</downloadable>
<purchase-url nil="true"/>
<label-id nil="true"/>
<purchase-title nil="true"/>
<genre>Metal</genre>
<title>Army Of God</title>
<description>
For more Information plea
EDIT:
I'd say you are right and SC Team should give an answer on that.

Related

Sportsipy API request

I need to use the sportsipy API to get the schedule for all teams in a dataframe. This is what I have:
from sportsreference.nba.schedule import Schedule
league = ['MIL','CHO','LAL','LAC','SAC','ATL','MIA','DAL','POR',
'HOU','NOP','PHO','WAS','MEM','BOS','DEN','TOR','SAS',
'PHI','BRK','UTA','IND','OKC','ORL','MIN','DET',
'NYK','CLE','CHI','GSW']
for i in league:
mil2019 = Schedule( i , year = '2020')
mil2019.dataframe_extended
The error i get is:
TypeError: unsupported operand type(s) for -: 'NoneType' and 'NoneType'
As mentioned above in the comment above, I believe your import is wrong. Using package sportsipy 0.6.0 and following the docs: https://sportsipy.readthedocs.io/en/stable/ I was able to achieve your desired result using following code:
from sportsipy.nba.schedule import Schedule
# MIL removed from league list as it is used to initiate league_schedule
league = ['CHO','LAL','LAC','SAC','ATL','MIA','DAL','POR',
'HOU','NOP','PHO','WAS','MEM','BOS','DEN','TOR','SAS',
'PHI','BRK','UTA','IND','OKC','ORL','MIN','DET',
'NYK','CLE','CHI','GSW']
league_schedule = Schedule('MIL', year="2020").dataframe
for team in league:
league_schedule = league_schedule.append(Schedule(team , year="2020").dataframe)
(Resulting dataframe has dimensions: [2286 rows x 15 columns])
Same should work with dataframe_extended, but it takes rather long time to get all that data. Maybe double check if you need all of it.
In case I am wrong and package you want to use in your question is correct please add additional info to your question, such as where can we get that package.
It appears you are using the module from pip install sportsreference from here which is on v0.5.2 in which case that is a valid import, even though you mentioned you're using sportsipy which caused some confusion for others. The latest version has refactored the package name to sportsipy.
If it wasn't a valid import, it would be throwing an import error on the very first line, so I'm not sure why folks are getting hung up on that.
You really should include the entire Python traceback, not just the final message, so we can determine exactly where in your code and the module's source code this exception is being raised. Also include the specific version of the library you're using, e.g. from pip freeze.
My initial thought is one of the requests somewhere for one of these teams is returning something unexpected and the library is not handling it properly, but without the full traceback that's just a theory.
It's probably a bug in v0.5.2 of sportsipy. I would try using the latest version from git and see if you can reproduce the error. Something, somewhere isn't validating things are what it expects before trying to do things with it. If I had the full traceback, I could tell you exactly what.
You could try catching the TypeError and passing on it, to see if skipping it allows everything else to continue working, but without knowing exactly where the error is coming from it's hard to say for sure at this point.
for i in league:
try:
mil2019 = Schedule( i , year = '2020')
mil2019.dataframe_extended
except TypeError:
pass
This won't fix the problem, it's actually hiding it, but if it's just one record from one game that is returning something unexpected this would at least let you get the rest of the results, possibly. It's also possible the issue would create other problems later, depending on exactly what it is. Again, this is where the whole traceback would have been helpful.
I will say that trying your code for just one team works for me. For example:
from sportsreference.nba.schedule import Schedule
mil2019 = Schedule("MIL", year="2020")
print(mil2019.dataframe_extended.head(10))
Returns this:
away_assist_percentage ... winning_name
201910240HOU 67.4 ... Milwaukee Bucks
201910260MIL 71.7 ... Miami Heat
201910280MIL 42.2 ... Cleveland Cavaliers
201910300BOS 55.3 ... Milwaukee Bucks
201911010ORL 51.1 ... Milwaukee Bucks
201911020MIL 70.6 ... Toronto Raptors
201911040MIN 48.0 ... Milwaukee Bucks
201911060LAC 42.9 ... Milwaukee Bucks
201911080UTA 41.2 ... Milwaukee Bucks
201911100OKC 57.4 ... Milwaukee Bucks
[10 rows x 82 columns]
It takes forever just to get the games from one team. The library is not passing around an existing requests.Session() when calling PyQuery (even though PyQuery supports a session kwarg), so every request for every box score is renegotiating a fresh TCP connection which is absurd, but I digress:
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): www.basketball-reference.com:80
DEBUG:urllib3.connectionpool:http://www.basketball-reference.com:80 "GET /teams/MIL/2020_games.html HTTP/1.1" 301 183
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): www.basketball-reference.com:443
DEBUG:urllib3.connectionpool:https://www.basketball-reference.com:443 "GET /teams/MIL/2020_games.html HTTP/1.1" 200 34571
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): www.basketball-reference.com:443
DEBUG:urllib3.connectionpool:https://www.basketball-reference.com:443 "GET /boxscores/201910240HOU.html HTTP/1.1" 200 46549
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): www.basketball-reference.com:443
I would add some debugging to your code to establish which team your code is working on when this exception is raised. Try first with one team like I did and confirm it generally works, then iterate through the list of teams with logging enabled like:
import logging
from sportsreference.nba.schedule import Schedule
logging.basicConfig(level=logging.DEBUG)
league = ['CHO', 'LAL', 'LAC', 'SAC', 'ATL', 'MIA', 'DAL', 'POR',
'HOU', 'NOP', 'PHO', 'WAS', 'MEM', 'BOS', 'DEN', 'TOR', 'SAS',
'PHI', 'BRK', 'UTA', 'IND', 'OKC', 'ORL', 'MIN', 'DET',
'NYK', 'CLE', 'CHI', 'GSW']
for i in league:
logging.info("Working on league: %s", i)
mil2019 = Schedule(i, year="2020")
print(mil2019.dataframe_extended)
This way you will know specifically what league and which specific request is responsible for the issue and that would help you determine what the root cause is.

WSO2 API Manager returning RunTime Error

I have an API in WSO2. When I try to test it in the store with valid parameters via GET, it returns the following error message:
<am:fault xmlns:am="http://wso2.org/apimanager">
<am:code>101504</am:code>
<am:type>Status report</am:type>
<am:message>Runtime Error</am:message>
<am:description>Send timeout</am:description>
</am:fault>
I have already searched and tried a lot, but with no success, always returning the same error. Don't know if helps, but the api that I try to access is a PHP file.
Any ideas?
EDIT:
I have identical apis to this one, changing only the response, that are working properly. Even if I erase the php file that the API is pointing, the error keep coming.
EDIT:
I changed the code in Management Console, in Metadata>List>APIs:
{"production_endpoints":
{"url":"http://site/myapi.php","config":
{"format":"leave-as-is","optimize":"leave-as-
is","actionSelect":"fault","actionDuration":30000}},
"sandbox_endpoints":
{"url":"http://site/myapi.php","config":
{"format":"leave-as-is","optimize":"leave-as-
is","actionSelect":"fault","actionDuration":30000}},
"implementation_status":"managed","endpoint_type":"http"}
to this:
{"production_endpoints":
{"url":"http://10.20.40.189/ConsultaAutorizacaoCadPos.php","config":null},
"sandbox_endpoints":{"url":"http://10.20.40.189/ConsultaAutorizacaoCadPos.php","config":null},
"implementation_status":"managed","endpoint_type":"http"}
And this error message vanishes. But this new one appears:
<am:fault xmlns:am="http://wso2.org/apimanager">
<am:code>303001</am:code>
<am:type>Status report</am:type>
<am:message>Runtime Error</am:message>
<am:description>Currently , Address endpoint : [ Name : admin--myapi_APIproductionEndpoint_0 ] [ State : SUSPENDED ]</am:description>
EDIT: this error message is appearing just sometimes. Most of the time the request takes long time to run and then returns nothing( no content )
Any ideas how to solve it?

Bit rate error when trying to dial out to an ISDN line using Polycom XML API

I am having a problem connecting to an ISDN line using Polycom's XML API on an RMX_2000. Below is the request I am sending, and the response. I can do the same action from the RMX Manager, for the same number, in the same conference, and it works. When I trace the XML from the RMX Manager, I get an ADD_PARTY request that looks exactly like my constructed request, except with a lot more elements. I've reviewed and don't see any that seem like they could be relevant, and I am loath to manually code every single element, knowing that it is a long shot that it will even help. The same request (variant) works fine for IP and registered number requests, but no matter what I do, always get the bit rate error below. Can anyone tell me what I am doing wrong?
<TRANS_CONF_1>
<TRANS_COMMON_PARAMS>
<MCU_TOKEN>304</MCU_TOKEN>
<MCU_USER_TOKEN>304</MCU_USER_TOKEN>
<MESSAGE_ID>1</MESSAGE_ID>
</TRANS_COMMON_PARAMS>
<ACTION>
<ADD_PARTY>
<ID>18466</ID>
<PARTY>
<ID>0</ID>
<NAME>isdn</NAME>
<PHONE_LIST>
<PHONE1>12345678910</PHONE1>
</PHONE_LIST>
<INTERFACE>isdn</INTERFACE>
<CONNECTION>dial_out</CONNECTION>
<MEET_ME_METHOD>party</MEET_ME_METHOD>
<NUM_TYPE>taken_from_service</NUM_TYPE>
<MULTI_RATE>auto</MULTI_RATE>
<ALIAS>
<NAME>12345678910</NAME>
<ALIAS_TYPE>323_id</ALIAS_TYPE>
</ALIAS>
<VIDEO_BIT_RATE>automatic</VIDEO_BIT_RATE>
<ENHANCED_VIDEO>false</ENHANCED_VIDEO>
<UNDEFINED>false</UNDEFINED>
</PARTY>
</ADD_PARTY>
</ACTION>
</TRANS_CONF_1>
Here is the response:
<RESPONSE_TRANS_CONF>
<RETURN_STATUS>
<ID>1015</ID>
<DESCRIPTION>Conference bit rate must be set to a minimum of 128Kbps to enable ISDN participant connection</DESCRIPTION>
<YOUR_TOKEN1>0</YOUR_TOKEN1>
<YOUR_TOKEN2>0</YOUR_TOKEN2>
<MESSAGE_ID>1</MESSAGE_ID>
<DESCRIPTION_EX></DESCRIPTION_EX>
</RETURN_STATUS>
<ACTION>
<ADD_PARTY/>
</ACTION>
</RESPONSE_TRANS_CONF>
Thanks to a little help from someone at Polycom, I found out that the following node is required for this:
auto
I added that to the PARTY node, and now all is well.
After alot of troubleshooting and wiresharking on this error I found a combination of 2 properties being the issue
Reservation object needs
<TRANSFER_RATE>384</TRANSFER_RATE>
Party object needs
<NET_CHANNEL_NUMBER>auto</NET_CHANNEL_NUMBER>

highrise API, put unprocessable entity , 37 Signals

i´m playing arround with the HIGHRISE API, and they understood the meaning of rest, its pretty cool and at some points gracefully forgivingly, but
has anybody any idea why the xml i PUT is not accepted ?
here is some relevant logging :
2014-02-23 00:00:04] app.INFO: Updating:Person:Highrise-API = people/11834527375.xml [] []
[2014-02-23 00:00:04] app.INFO: request body is :
<?xml version="1.0" encoding="UTF-8"?>
<person>
<first-name><![CDATA[Johnny]]></first-name>
<last-name><![CDATA[B. Good]]></last-name>
<visible-to><![CDATA[Everyone]]></visible-to>
<subject_datas type="array">
<subject_data>
<subject_field_id type="integer"><![CDATA[43212]]></subject_field_id>
<value><![CDATA[dsa328394OOKD323H]]></value>
</subject_data>
<subject_data>
<subject_field_id type="integer"><![CDATA[470259]]></subject_field_id>
<value><![CDATA[provider://w184071823/fmdks/2032]]></value>
</subject_data>
<subject_data>
<subject_field_id type="integer"><![CDATA[469130]]></subject_field_id>
<value><![CDATA[CORE]]></value>
</subject_data>
<subject_data>
<subject_field_id type="integer"><![CDATA[469132]]></subject_field_id>
<value><![CDATA[Way too cool]]></value>
</subject_data>
</subject_datas>
<contact-data>
<phone-numbers>
<phone-number type="array">
<number><![CDATA[081 6418273]]></number>
<location><![CDATA[Work]]></location>
</phone-number>
</phone-numbers>
<addresses type="array">
<address>
<city><![CDATA[New York City]]></city>
<country><![CDATA[US]]></country>
<state><![CDATA[New York]]></state>
<street><![CDATA[Siplingerstreet 11]]></street>
<zip><![CDATA[87527]]></zip>
<location><![CDATA[Work]]></location>
</address>
</addresses>
</contact-data>
</person>
[] []
[2014-02-23 00:00:04] app.INFO: request set [] []
[2014-02-23 00:00:04] app.ERROR: Guzzle/3.8.1 curl/7.28.1 PHP/5.4.10 - [2014-02-22T23:00:04+00:00] "PUT /people/11834527375.xml HTTP/1.1" 422 103 [] []
[2014-02-23 00:00:04] app.INFO: Caught client-error-exception in HighriseService updatePerson(): exception 'Guzzle\Http\Exception\ClientErrorResponseException' with message 'Client error response
[status code] 422
[reason phrase] Unprocessable Entity
i dont see the error :/
I´m very sure the subject_field_id´s are correct and those custom fields are set
Posting e.g saving that xml works, i saw from the response that are fields were set,
only thing i can guess is, that i´m trying to PUT a version where nothing has changed,
is that the problem ?
because my code only checks if that person exists at all and if so update it instead of creating
You should get back some XML in the body of the response. It should look like this:
<?xml version="1.0" encoding="UTF-8"?>
<errors>
<error>Phone number '555-555-5555' has already been taken</error>
</errors>
If you include the id for the existing phone number in your PUT request, then we know that you want to update the existing address, rather than adding a new one: https://github.com/basecamp/highrise-api/blob/master/sections/people.md#update-person
Contact data and Subject data that include an id will be updated, data that doesn’t will be assumed to be new and created from scratch. To remove a piece of data, prefix its id with a minus sign (e.g. -1).

QuickBooks API Invoice <DueDate> tag

I wrote a custom integration between a SQL Server based system and QuickBooks many years ago which automatically creates invoices in QuickBooks from data in SQL Server. The XML string to create the invoices is quite simple:
<QBXML>
<QBXMLMsgsRq newMessageSetID="10025027" onError="continueOnError">
<InvoiceAddRq requestID="10025027">
<InvoiceAdd>
<CustomerRef>
<FullName>Acme Corporation, Inc.</FullName>
</CustomerRef>
<TxnDate>2014-02-05</TxnDate>
<RefNumber>124</RefNumber>
<ShipAddress>
<Addr1>16-01 16th Avenue, Dock 3</Addr1>
<Addr2/>
<Addr3/>
<Addr4/>
<City>Astoria</City>
<State>NY</State>
<PostalCode>11105</PostalCode>
</ShipAddress>
<PONumber> 6028019</PONumber>
<SalesRepRef>
<FullName>H</FullName>
</SalesRepRef>
<Memo>1401106</Memo>
<InvoiceLineAdd>
<ItemRef>
<FullName>SALES</FullName>
</ItemRef>
<Desc> Semi Annual Sampling - M1; Day 1</Desc>
<Rate>5580</Rate>
</InvoiceLineAdd>
</InvoiceAdd>
</InvoiceAddRq>
</QBXMLMsgsRq>
</QBXML>
The SQL Server based system actually prints detailed invoices which are delivered to the customer, QuickBooks is only used to keep track of account balances and payments. I am now trying to add the DueDate to the invoice by adding the following XML tag:
<DueDate>2014-03-07</DueDate>
I have tried to place this tag in several places in the XML string but QuickBooks rejects the request with the following error:
"QuickBooks found an error when parsing the provided XML text stream."
The bookkeeper is able to manually change the due date on the invoices after they are created, but for some reason I can't specify the due date when creating the invoices with the QuickBooks API. Any Ideas?
Thanks.
A few things to note here:
This is an incomplete qbXML request. There should be an XML and qbXML header tag as the very first two lines, and you're missing them. They should look like this:
<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="13.0"?>
That version="..." bit should be set to something your version of QuickBooks supports (generally your QuickBooks version - 1, e.g. QuickBooks 2012 supports qbXML version 11.0, QuickBooks 2013 supports qbXML version 12.0, QuickBooks 2014 supports qbXML version 13.0, etc.)
Your post doesn't even show the DueDate field in the XML, so it's a little hard to tell what's actually wrong, but...
Keep in mind that the order of tags in qbXML is important. So if the OSR shows the DueDate field after PONumber, you better make darn sure to put it after the PONumber field. If you put it before it, you're going to get exactly the error you described.
Did you use the OSR to find the correct place? There shouldn't be any guess-work here - it tells you exactly where to put it.
...
<State>NY</State>
<PostalCode>11105</PostalCode>
</ShipAddress>
<PONumber> 6028019</PONumber>
<DueDate>2014-02-12</DueDate
<SalesRepRef>
<FullName>H</FullName>
</SalesRepRef>
<Memo>1401106</Memo>
...
I think the missing header tags were the problem. (I also added the <TermsRef> tag)
Here is the XML that did the trick:
<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="11.0"?>
<QBXML>
<QBXMLMsgsRq newMessageSetID="10025079" onError="continueOnError">
<InvoiceAddRq requestID="10025079">
<InvoiceAdd>
<CustomerRef>
<FullName>Acme Corporation</FullName>
</CustomerRef>
<TxnDate>2014-02-13</TxnDate>
<RefNumber>168</RefNumber>
<ShipAddress>
<Addr1>Acme Corporation</Addr1>
<Addr2>1587-43 Veteran's Highway</Addr2>
<Addr3/>
<Addr4/>
<City>Islandia</City>
<State>NY</State>
<PostalCode>11749</PostalCode>
</ShipAddress>
<PONumber>5A873929B</PONumber>
<TermsRef>
<FullName>30 Days</FullName>
</TermsRef>
<DueDate>2014-03-15</DueDate>
<SalesRepRef>
<FullName>H</FullName>
</SalesRepRef>
<Memo>1402016</Memo>
<InvoiceLineAdd>
<ItemRef>
<FullName>SALES</FullName>
</ItemRef>
<Desc> OBAR Auto Parts, 279 South Street, Oyster Bay, NY 11771</Desc>
<Rate>1760</Rate>
</InvoiceLineAdd>
</InvoiceAdd>
</InvoiceAddRq>
</QBXMLMsgsRq>
</QBXML>
Thank you again!