so all of a sudden I'm getting this error in my unity project.
InvalidOperationException: HTTP/1.1 403 Forbidden
UnityEngine.Networking.DownloadHandler.GetCheckedDownloader[T] (UnityEngine.Networking.UnityWebRequest www) (at /Users/bokken/buildslave/unity/build/Modules/UnityWebRequest/Public/DownloadHandler/DownloadHandler.bindings.cs:145)
UnityEngine.Networking.DownloadHandlerAssetBundle.GetContent (UnityEngine.Networking.UnityWebRequest www) (at /Users/bokken/buildslave/unity/build/Modules/UnityWebRequestAssetBundle/Public/DownloadHandlerAssetBundle.bindings.cs:64)
API+<GetDisplayBundleRoutine>d__5.MoveNext () (at /Users/remy/Unity/AREA/Assets/Scripts/API.cs:58)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at /Users/bokken/buildslave/unity/build/Runtime/Export/Scripting/Coroutines.cs:17)
I'm using my own website/server to request an asset bundle. I believe I recently updated the php version to 7.4 of the webserver. Could that be part of the problem? No sure if that is related.
Underneath the script which I use to sort the asset bundles from the server within the app. Not sure if that is related to my current problem though.
I'm requesting bundle in my app via this php-script om the server.
// The tab key will cycle through the settings when first created
// Visit https://codexns.io/products/sftp_for_subime/settings for help
// sftp, ftp or ftps
"type": "sftp",
"save_before_upload": true,
"upload_on_save": false,
"sync_down_on_open": false,
"sync_skip_deletes": false,
"sync_same_age": true,
"confirm_downloads": false,
"confirm_sync": true,
"confirm_overwrite_newer": false,
"host": "ssh.strato.com",
"user": "******",
"password": "******",
"port": "22",
"remote_path": "/",
"ignore_regexes": [
"\\.sublime-(project|workspace)", "sftp-config(-alt\\d?)?\\.json",
"sftp-settings\\.json", "/venv/", "\\.svn/", "\\.hg/", "\\.git/",
"\\.bzr", "_darcs", "CVS", "\\.DS_Store", "Thumbs\\.db", "desktop\\.ini"
],
//"file_permissions": "664",
//"dir_permissions": "775",
//"extra_list_connections": 0,
"connect_timeout": 30,
//"keepalive": 120,
//"ftp_passive_mode": true,
//"ftp_obey_passive_host": false,
//"ssh_key_file": "~/.ssh/id_rsa",
//"sftp_flags": ["-F", "/path/to/ssh_config"],
//"preserve_modification_times": false,
//"remote_time_offset_in_hours": 0,
//"remote_encoding": "utf-8",
//"remote_locale": "C",
//"allow_config_upload": false,
}
This is the script I use for api access:
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Networking;
public class API : MonoBehaviour {
const string BundleFolder = "https://www.remykonings.nl/AssetBundles/";
const string ItemList = "https://www.remykonings.nl/ItemList.php";
public void GetItemList(UnityAction<List<string>> callback) {
StartCoroutine(GetItemListRoutine(callback));
}
IEnumerator GetItemListRoutine(UnityAction<List<string>> callback) {
UnityWebRequest www = UnityWebRequest.Get(ItemList);
yield return www.SendWebRequest();
if (www.result == UnityWebRequest.Result.ConnectionError) {
Debug.Log("Network error");
} else {
string rawText = www.downloadHandler.text;
//split string by comma
string[] items = rawText.Split(',');
//remove empty values and convert to list
List<string> itemList = items.Where(x => !string.IsNullOrEmpty(x)).ToList();
//return list to caller
callback.Invoke(itemList);
}
}
public void GetBundleObject(string assetName, UnityAction<GameObject> callback, Transform bundleParent) {
StartCoroutine(GetDisplayBundleRoutine(assetName, callback, bundleParent));
}
IEnumerator GetDisplayBundleRoutine(string assetName, UnityAction<GameObject> callback, Transform bundleParent) {
string bundleURL = BundleFolder + assetName + "-";
//append platform to asset bundle name
#if UNITY_ANDROID
bundleURL += "Android";
#else
bundleURL += "IOS";
#endif
Debug.Log("Requesting bundle at " + bundleURL);
//request asset bundle
UnityWebRequest www = UnityWebRequestAssetBundle.GetAssetBundle(bundleURL);
yield return www.SendWebRequest();
if (www.result == UnityWebRequest.Result.ConnectionError) {
Debug.Log("Network error");
} else {
AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(www);
if (bundle != null) {
string rootAssetPath = bundle.GetAllAssetNames()[0];
GameObject arObject = Instantiate(bundle.LoadAsset(rootAssetPath) as GameObject,bundleParent);
bundle.Unload(false);
callback(arObject);
} else {
Debug.Log("Not a valid asset bundle");
}
}
}
}
I'm fairly new at all of this. Hoping for some help :)
Thank you.