Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect URL & POST tracks issues - "Oh no! We can’t find that page. Check the address and try again?" #337

Open
hannah-subtle opened this issue Oct 18, 2024 · 4 comments
Labels
question Further information is requested

Comments

@hannah-subtle
Copy link

Title: Cannot Auth to use POST tracks path

Issue found of: September 20th, 2020

Endpoint(s):

  • GET /users/{id}/tracks

Scope(s):

  • none

Steps to reproduce:

Using this URL - https://soundcloud.com/connect?client_id={client_id}&redirect_uri={redirect_uri}&response_type=code"

But I get the error - "Oh no! We can’t find that page. Check the address and try again?" after clicking connect

@youssefhassan
Copy link

Hey Hannah, what are you trying to achieve here? As I see GET /users/{id}/tracks and in the steps to reproduce the call is for connect endpoint? Also the host on the connect URL is wrong, it should be secure.soundcloud.com for authentication URLs and api.soundcloud.com for other functions

@youssefhassan youssefhassan added the question Further information is requested label Oct 21, 2024
@hannah-subtle
Copy link
Author

Hello @youssefhassan

I have this working now but am having trouble setting this up in js. Are there any examples of post tracks using a js application?

Thanks,

@youssefhassan
Copy link

This is an example of a CURL request

curl -v -X 'POST' \
  'https://api.soundcloud.com/tracks' \
  -H 'accept: application/json; charset=utf-8' \
  -H 'Authorization: VALID_TOKEN' \
  -H 'Content-Type: multipart/form-data' \
  -F 'track[sharing]=private' \
  -F 'track[asset_data][email protected]' \
  -F 'track[title]=TTTT' 

This is an example from a Python method too
`def upload_track(self):
url = f"{self.base_url}/tracks"
copy = self.headers.copy()
copy.update({'accept': 'application/json; charset=utf-8'})

    # Define the parameters as a dictionary
    params = {
        'track[sharing]': 'private',
        'track[title]': 'Test Track from Python',
    }

    # Open and read the file
    file_path = 'path/track_name.mp3'  
    with open(file_path, 'rb') as file:
        # Prepare the file parameter
        files = {'track[asset_data]': ('test', file, 'type=audio/x-m4a')}

        # Make the POST request with file and params
        response = requests.post(url, headers=copy, files=files, data=params)
        # print(curlify.to_curl(response.request))
    if response.status_code != 201:
        return [None, response.status_code]
    return [response.json()['id'], response.status_code]`

@youssefhassan
Copy link

Let me know if this helps and if not, what are the challenges you are currently facing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants