Azure / azure-notificationhubs-java-backend

Azure Notification Hubs SDK for Java
https://docs.microsoft.com/en-us/azure/notification-hubs/
Apache License 2.0
35 stars 49 forks source link

[BUG] 400 Bad Request when exporting registrations #119

Closed yangchengs closed 2 years ago

yangchengs commented 2 years ago

This is a cx reporting issue and I can reproduce the same thing. The notification hub is standard tier. When I run the sample code, it gives me error: Error: HTTP/1.1 400 Bad Request - 400The supplied notificationhub job payload is invalid.TrackingId:85871df2-dd9d-48d5-b435-b7539879f3d1_G14,TimeStamp:2/1/2022 1:44:36 AM

pom.xml

com.windowsazure Notification-Hubs-java-sdk 0.4.2

code:

import com.windowsazure.messaging.NotificationHub; import com.windowsazure.messaging.NotificationHubJob; import com.windowsazure.messaging.NotificationHubJobStatus; import com.windowsazure.messaging.NotificationHubJobType;

public class NotificationHubTest {

public static void main(String[] args) {
    // TODO Auto-generated method stub
    // Submit an export job
    NotificationHub hub = new NotificationHub("Endpoint=sb://myhubspace2.servicebus.windows.net/;SharedAccessKeyName=DefaultFullSharedAccessSignature;SharedAccessKey=xpPzFQR9etp9/UEUi6trxUpP6IEBAixV67AnqkoI5Tc=", "myhub002");

    try

    {
        NotificationHubJob job = new NotificationHubJob();
        job.setJobType(NotificationHubJobType.ExportRegistrations);
        job.setOutputContainerUri("https://yangshendls12312.blob.core.windows.net/dir1?sv=2018-03-28&sr=c&sig=1VI51zRmC71DHo2%2Ft1SfRcXUAYde%2BloFd8Xow15Ozy8%3D&se=2022-02-01T04%3A41%3A05Z&sp=rwl");
        job = hub.submitNotificationHubJob(job);

        // Wait until the job is done
        while(true){
            Thread.sleep(1000);
            job = hub.getNotificationHubJob(job.getJobId());
            if(job.getJobStatus() == NotificationHubJobStatus.Completed)
                break;
        }
    }
    catch (Exception ex)
    {
        System.out.print(ex.getMessage());          
    }
}

}

yangchengs commented 2 years ago

I tested version 1.0.0, and it gives me the same error.